diff --git a/Makefile b/Makefile index 221ede2..879bdf9 100644 --- a/Makefile +++ b/Makefile @@ -147,6 +147,7 @@ php-cs-fixer-apply: ## Execute php-cs-fixer and apply changes .PHONY: tests tests: ## Execute tests $(APP) vendor/bin/simple-phpunit --configuration ./tests/phpunit.xml.dist --colors=always --testdox + $(APP) vendor/bin/behat --config ./tests/behat.yml ## ## —— ✨ Others —— diff --git a/composer.json b/composer.json index 8adac39..ec89c91 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "symfony/yaml": "^7.0" }, "require-dev": { + "friends-of-behat/symfony-extension": "^2.0", "friendsofphp/php-cs-fixer": "^3.37", "nunomaduro/phpinsights": "^2.8", "phpstan/extension-installer": "^1.2", diff --git a/composer.lock b/composer.lock index a84d814..a2f7eca 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": "41bf8e24124ffae978bd799942d47e05", + "content-hash": "eedee26c03b98f17a3b74702a0c6f61c", "packages": [ { "name": "doctrine/cache", @@ -4143,6 +4143,205 @@ }, "time": "2021-12-16T21:41:27+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": "cmgmyr/phploc", "version": "8.0.3", @@ -4504,6 +4703,74 @@ }, "time": "2023-01-05T11:28:13+00:00" }, + { + "name": "friends-of-behat/symfony-extension", + "version": "v2.5.0", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfBehat/SymfonyExtension.git", + "reference": "92653f5c8a5d14300434411eb76aed584802e722" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfBehat/SymfonyExtension/zipball/92653f5c8a5d14300434411eb76aed584802e722", + "reference": "92653f5c8a5d14300434411eb76aed584802e722", + "shasum": "" + }, + "require": { + "behat/behat": "^3.6.1", + "php": "^8.1", + "symfony/dependency-injection": "^6.2 || ^7.0", + "symfony/http-kernel": "^6.2 || ^7.0" + }, + "require-dev": { + "behat/mink": "^1.9", + "behat/mink-browserkit-driver": "^2.0", + "behat/mink-selenium2-driver": "^1.3", + "friends-of-behat/mink-extension": "^2.5", + "friends-of-behat/page-object-extension": "^0.3.2", + "friends-of-behat/service-container-extension": "^1.1", + "sylius-labs/coding-standard": ">=4.1.1, <=4.2.1", + "symfony/browser-kit": "^6.2 || ^7.0", + "symfony/framework-bundle": "^6.2 || ^7.0", + "symfony/process": "^6.2 || ^7.0", + "symfony/yaml": "^6.2 || ^7.0", + "vimeo/psalm": "4.30.0" + }, + "suggest": { + "behat/mink": "^1.9", + "behat/mink-browserkit-driver": "^2.0", + "friends-of-behat/mink-extension": "^2.5" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "psr-4": { + "FriendsOfBehat\\SymfonyExtension\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kamil Kokot", + "email": "kamil@kokot.me", + "homepage": "https://kamilkokot.com" + } + ], + "description": "Integrates Behat with Symfony.", + "support": { + "issues": "https://github.com/FriendsOfBehat/SymfonyExtension/issues", + "source": "https://github.com/FriendsOfBehat/SymfonyExtension/tree/v2.5.0" + }, + "time": "2024-01-11T14:57:03+00:00" + }, { "name": "friendsofphp/php-cs-fixer", "version": "v3.46.0", diff --git a/tests/Behat/DemoContext.php b/tests/Behat/DemoContext.php new file mode 100644 index 0000000..51f29e0 --- /dev/null +++ b/tests/Behat/DemoContext.php @@ -0,0 +1,48 @@ +kernel = $kernel; + } + + /** + * @When a demo scenario sends a request to :path + */ + public function aDemoScenarioSendsARequestTo(string $path): void + { + $this->response = $this->kernel->handle(Request::create($path, 'GET')); + } + + /** + * @Then the response should be received + */ + public function theResponseShouldBeReceived(): void + { + if ($this->response === null) { + throw new \RuntimeException('No response received'); + } + } +} diff --git a/tests/Behat/features/demo.feature b/tests/Behat/features/demo.feature new file mode 100644 index 0000000..78fead8 --- /dev/null +++ b/tests/Behat/features/demo.feature @@ -0,0 +1,12 @@ +# This file contains a user story for demonstration only. +# Learn how to get started with Behat and BDD on Behat's website: +# http://behat.org/en/latest/quick_start.html + +Feature: + In order to prove that the Behat Symfony extension is correctly installed + As a user + I want to have a demo scenario + + Scenario: It receives a response from Symfony's kernel + When a demo scenario sends a request to "/" + Then the response should be received \ No newline at end of file diff --git a/tests/behat.yml b/tests/behat.yml new file mode 100644 index 0000000..21d5b2b --- /dev/null +++ b/tests/behat.yml @@ -0,0 +1,11 @@ +default: + suites: + default: + paths: + features: tests/Behat/features + contexts: + - App\Tests\Behat\DemoContext + + extensions: + FriendsOfBehat\SymfonyExtension: + bootstrap: 'tests/bootstrap.php' \ No newline at end of file