From 0d774daca0185bdd0302d044f47a466ba6831c35 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 1 Mar 2024 20:33:01 +0000 Subject: [PATCH] Add Behat Add Behat as a dev dependency and add the example `ls` example. Due to a deprecation error, I needed to downgrade to PHP 8.1 on stream, though this would error the main `app:generate` command as I'm using `readonly` classes that were introduced in PHP 8.2. --- composer.json | 1 + composer.lock | 203 +++++++++++++++++++++++- features/bootstrap/FeatureContext.php | 64 ++++++++ features/ls.feature | 15 ++ flake.nix | 24 +-- src/DataTransferObject/TemplateFile.php | 8 +- 6 files changed, 293 insertions(+), 22 deletions(-) create mode 100644 features/bootstrap/FeatureContext.php create mode 100644 features/ls.feature diff --git a/composer.json b/composer.json index 8749c1d..2a88f86 100644 --- a/composer.json +++ b/composer.json @@ -70,6 +70,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8", + "behat/behat": "^3.14", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.5", "symfony/browser-kit": "^6.4", diff --git a/composer.lock b/composer.lock index 259edd1..af7c08b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8f7c72036cf473ae396a2e66a30c45a1", + "content-hash": "e7d5bf85313a3f5cb74e96149e0c01ec", "packages": [ { "name": "doctrine/annotations", @@ -4504,6 +4504,205 @@ }, "time": "2022-10-31T08:38:03+00:00" }, + { + "name": "behat/behat", + "version": "v3.14.0", + "source": { + "type": "git", + "url": "https://github.com/Behat/Behat.git", + "reference": "2a3832d9cb853a794af3a576f9e524ae460f3340" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Behat/Behat/zipball/2a3832d9cb853a794af3a576f9e524ae460f3340", + "reference": "2a3832d9cb853a794af3a576f9e524ae460f3340", + "shasum": "" + }, + "require": { + "behat/gherkin": "^4.9.0", + "behat/transliterator": "^1.2", + "ext-mbstring": "*", + "php": "^7.2 || ^8.0", + "psr/container": "^1.0 || ^2.0", + "symfony/config": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/console": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/event-dispatcher": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/translation": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/yaml": "^4.4 || ^5.0 || ^6.0 || ^7.0" + }, + "require-dev": { + "herrera-io/box": "~1.6.1", + "phpspec/prophecy": "^1.15", + "phpunit/phpunit": "^8.5 || ^9.0", + "symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "vimeo/psalm": "^4.8" + }, + "suggest": { + "ext-dom": "Needed to output test results in JUnit format." + }, + "bin": [ + "bin/behat" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Behat\\Hook\\": "src/Behat/Hook/", + "Behat\\Step\\": "src/Behat/Step/", + "Behat\\Behat\\": "src/Behat/Behat/", + "Behat\\Testwork\\": "src/Behat/Testwork/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + } + ], + "description": "Scenario-oriented BDD framework for PHP", + "homepage": "http://behat.org/", + "keywords": [ + "Agile", + "BDD", + "ScenarioBDD", + "Scrum", + "StoryBDD", + "User story", + "business", + "development", + "documentation", + "examples", + "symfony", + "testing" + ], + "support": { + "issues": "https://github.com/Behat/Behat/issues", + "source": "https://github.com/Behat/Behat/tree/v3.14.0" + }, + "time": "2023-12-09T13:55:02+00:00" + }, + { + "name": "behat/gherkin", + "version": "v4.9.0", + "source": { + "type": "git", + "url": "https://github.com/Behat/Gherkin.git", + "reference": "0bc8d1e30e96183e4f36db9dc79caead300beff4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Behat/Gherkin/zipball/0bc8d1e30e96183e4f36db9dc79caead300beff4", + "reference": "0bc8d1e30e96183e4f36db9dc79caead300beff4", + "shasum": "" + }, + "require": { + "php": "~7.2|~8.0" + }, + "require-dev": { + "cucumber/cucumber": "dev-gherkin-22.0.0", + "phpunit/phpunit": "~8|~9", + "symfony/yaml": "~3|~4|~5" + }, + "suggest": { + "symfony/yaml": "If you want to parse features, represented in YAML files" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Behat\\Gherkin": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + } + ], + "description": "Gherkin DSL parser for PHP", + "homepage": "http://behat.org/", + "keywords": [ + "BDD", + "Behat", + "Cucumber", + "DSL", + "gherkin", + "parser" + ], + "support": { + "issues": "https://github.com/Behat/Gherkin/issues", + "source": "https://github.com/Behat/Gherkin/tree/v4.9.0" + }, + "time": "2021-10-12T13:05:09+00:00" + }, + { + "name": "behat/transliterator", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/Behat/Transliterator.git", + "reference": "baac5873bac3749887d28ab68e2f74db3a4408af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Behat/Transliterator/zipball/baac5873bac3749887d28ab68e2f74db3a4408af", + "reference": "baac5873bac3749887d28ab68e2f74db3a4408af", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "require-dev": { + "chuyskywalker/rolling-curl": "^3.1", + "php-yaoi/php-yaoi": "^1.0", + "phpunit/phpunit": "^8.5.25 || ^9.5.19" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Behat\\Transliterator\\": "src/Behat/Transliterator" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Artistic-1.0" + ], + "description": "String transliterator", + "keywords": [ + "i18n", + "slug", + "transliterator" + ], + "support": { + "issues": "https://github.com/Behat/Transliterator/issues", + "source": "https://github.com/Behat/Transliterator/tree/v1.5.0" + }, + "time": "2022-03-30T09:27:43+00:00" + }, { "name": "doctrine/instantiator", "version": "2.0.0", @@ -6814,5 +7013,5 @@ "platform-overrides": { "php": "8.2" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php new file mode 100644 index 0000000..27ed36d --- /dev/null +++ b/features/bootstrap/FeatureContext.php @@ -0,0 +1,64 @@ +output = trim(implode("\n", $output)); + } + + /** + * @Then I should get: + */ + public function iShouldGet(PyStringNode $string) + { + if ((string) $string !== $this->output) { + throw new Exception( + "Actual output is:\n" . $this->output + ); + } + } +} diff --git a/features/ls.feature b/features/ls.feature new file mode 100644 index 0000000..7c9bbcb --- /dev/null +++ b/features/ls.feature @@ -0,0 +1,15 @@ +Feature: ls + In order to see the directory structure + As a UNIX user + I need to be able to list the current directory's contents + + Scenario: List 2 files in a directory + Given I am in a directory "test" + And I have a file named "foo" + And I have a file named "bar" + When I run "ls" + Then I should get: + """ + bar + foo + """ diff --git a/flake.nix b/flake.nix index fd96c20..a149852 100644 --- a/flake.nix +++ b/flake.nix @@ -1,32 +1,24 @@ # Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + { inputs = { devshell.url = "github:numtide/devshell"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = inputs @ {flake-parts, ...}: - flake-parts.lib.mkFlake {inherit inputs;} { - imports = [inputs.devshell.flakeModule]; + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ inputs.devshell.flakeModule ]; - systems = ["x86_64-linux"]; + systems = [ "x86_64-linux" ]; - perSystem = { - config, - self', - inputs', - pkgs, - system, - ... - }: { + perSystem = { config, self', inputs', pkgs, system, ... }: { devshells.default = { packages = with pkgs; [ - "php82" - "php82Packages.composer" + "php81" + "php81Packages.composer" ]; }; - - formatter = pkgs.alejandra; }; }; } diff --git a/src/DataTransferObject/TemplateFile.php b/src/DataTransferObject/TemplateFile.php index a3ea878..744a7e8 100644 --- a/src/DataTransferObject/TemplateFile.php +++ b/src/DataTransferObject/TemplateFile.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace App\DataTransferObject; -readonly final class TemplateFile +final class TemplateFile { public function __construct( - public string $data, - public string $name, - public string|null $path = null, + readonly public string $data, + readonly public string $name, + readonly public string|null $path = null, ) { } }