From fdaa3baf1180c03f0fd65291e30f47eb4baa714b Mon Sep 17 00:00:00 2001 From: Alan Gabriel Bem Date: Tue, 6 Apr 2021 07:09:03 +0200 Subject: [PATCH 1/4] skeleton setup for behat testing --- .env.local.dist | 1 - .github/workflows/ci.yaml | 40 ++++-- .gitignore | 4 + behat.yml.dist | 22 ++++ config/bundles.php | 1 + config/packages/translation.yaml | 6 + config/services/productivity/behat.yaml | 7 ++ config/services/shared/behat.yaml | 7 ++ config/services_test.yaml | 4 + features/productivity/lifecycle.feature | 26 ++++ .../Infrastructure/Behat/DomainContext.php | 114 ++++++++++++++++++ .../Infrastructure/Behat/RestContext.php | 114 ++++++++++++++++++ .../Infrastructure/Behat/StreakContext.php | 65 ++++++++++ symfony.lock | 37 ++++++ translations/.gitignore | 0 15 files changed, 437 insertions(+), 11 deletions(-) delete mode 100644 .env.local.dist create mode 100644 behat.yml.dist create mode 100644 config/packages/translation.yaml create mode 100644 config/services/productivity/behat.yaml create mode 100644 config/services/shared/behat.yaml create mode 100644 config/services_test.yaml create mode 100644 features/productivity/lifecycle.feature create mode 100644 src/Productivity/Infrastructure/Behat/DomainContext.php create mode 100644 src/Productivity/Infrastructure/Behat/RestContext.php create mode 100644 src/Shared/Infrastructure/Behat/StreakContext.php create mode 100644 translations/.gitignore diff --git a/.env.local.dist b/.env.local.dist deleted file mode 100644 index cdb0a7f..0000000 --- a/.env.local.dist +++ /dev/null @@ -1 +0,0 @@ -APP_ENV=dev diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 42439ea..820ac9a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,8 +9,8 @@ jobs: uses: actions/checkout@v2 - name: Docker pull run: docker-compose pull php -# - name: Docker build -# run: docker-compose build --force-rm + # - name: Docker build + # run: docker-compose build --force-rm - name: Run composer validate run: docker-compose run --rm --no-deps php composer validate --strict --no-interaction --ansi run-php-cs-fixer: @@ -21,8 +21,8 @@ jobs: uses: actions/checkout@v2 - name: Docker pull run: docker-compose pull php -# - name: Docker build -# run: docker-compose build --force-rm + # - name: Docker build + # run: docker-compose build --force-rm - name: Composer caching uses: actions/cache@v2 with: @@ -41,8 +41,8 @@ jobs: uses: actions/checkout@v2 - name: Docker pull run: docker-compose pull -# - name: Docker build -# run: docker-compose build --force-rm + # - name: Docker build + # run: docker-compose build --force-rm - name: Composer caching uses: actions/cache@v2 with: @@ -73,8 +73,8 @@ jobs: uses: actions/checkout@v2 - name: Docker pull run: docker-compose pull php -# - name: Docker build -# run: docker-compose build --force-rm + # - name: Docker build + # run: docker-compose build --force-rm - name: Composer caching uses: actions/cache@v2 with: @@ -93,8 +93,8 @@ jobs: uses: actions/checkout@v2 - name: Docker pull run: docker-compose pull php -# - name: Docker build -# run: docker-compose build --force-rm + # - name: Docker build + # run: docker-compose build --force-rm - name: Composer caching uses: actions/cache@v2 with: @@ -105,3 +105,23 @@ jobs: run: docker-compose run --rm --no-deps php composer install --no-scripts --no-interaction --optimize-autoloader --ansi - name: Run deptrac run: docker-compose run --rm --no-deps php bin/deptrac --no-progress --no-interaction --cache-file=./build/.deptrac/.deptrac.cache --ansi + run-behat: + name: behat + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Docker pull + run: docker-compose pull php + # - name: Docker build + # run: docker-compose build --force-rm + - name: Composer caching + uses: actions/cache@v2 + with: + path: ./build/.composer + key: ${{ runner.os }}-composer-v1-${{ hashFiles('composer.lock') }} + restore-keys: ${{ runner.os }}-composer-v1- + - name: Install dependencies + run: docker-compose run --rm --no-deps php composer install --no-scripts --no-interaction --optimize-autoloader --ansi + - name: Run behat + run: docker-compose run --rm php xphp bin/behat --format=progress diff --git a/.gitignore b/.gitignore index 5573c1e..423c1b3 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,7 @@ ###> qossmic/deptrac-shim ### /.deptrac.cache ###< qossmic/deptrac-shim ### + +###> friends-of-behat/symfony-extension ### +/behat.yml +###< friends-of-behat/symfony-extension ### diff --git a/behat.yml.dist b/behat.yml.dist new file mode 100644 index 0000000..ada2e4f --- /dev/null +++ b/behat.yml.dist @@ -0,0 +1,22 @@ +default: + suites: + domain: + paths: + - features/productivity + contexts: + - Productivity\Infrastructure\Behat\DomainContext + - Shared\Infrastructure\Behat\StreakContext + rest: + paths: + - features/productivity + contexts: + - Productivity\Infrastructure\Behat\RestContext + + extensions: + FriendsOfBehat\SymfonyExtension: + bootstrap: tests/bootstrap.php # reused bootstrap of phpunit + kernel: + class: Kernel + path: ~ + environment: ~ + debug: ~ diff --git a/config/bundles.php b/config/bundles.php index f6e1b84..2954ae6 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -24,4 +24,5 @@ Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], OldSound\RabbitMqBundle\OldSoundRabbitMqBundle::class => ['all' => true], + FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true], ]; diff --git a/config/packages/translation.yaml b/config/packages/translation.yaml new file mode 100644 index 0000000..05a2b3d --- /dev/null +++ b/config/packages/translation.yaml @@ -0,0 +1,6 @@ +framework: + default_locale: en + translator: + default_path: '%kernel.project_dir%/translations' + fallbacks: + - en diff --git a/config/services/productivity/behat.yaml b/config/services/productivity/behat.yaml new file mode 100644 index 0000000..235c450 --- /dev/null +++ b/config/services/productivity/behat.yaml @@ -0,0 +1,7 @@ +services: + _defaults: + autowire: true + autoconfigure: true + + Productivity\Infrastructure\Behat\: + resource: '%kernel.project_dir%/src/Productivity/Infrastructure/Behat' diff --git a/config/services/shared/behat.yaml b/config/services/shared/behat.yaml new file mode 100644 index 0000000..39a5986 --- /dev/null +++ b/config/services/shared/behat.yaml @@ -0,0 +1,7 @@ +services: + _defaults: + autowire: true + autoconfigure: true + + Shared\Infrastructure\Behat\: + resource: '%kernel.project_dir%/src/Shared/Infrastructure/Behat' diff --git a/config/services_test.yaml b/config/services_test.yaml new file mode 100644 index 0000000..290396d --- /dev/null +++ b/config/services_test.yaml @@ -0,0 +1,4 @@ +services: + streak.snapshotter: '@streak.null.snapshotter' + streak.subscription_dao: '@streak.in_memory.subscription_dao' + streak.event_store: '@streak.in_memory.event_store' diff --git a/features/productivity/lifecycle.feature b/features/productivity/lifecycle.feature new file mode 100644 index 0000000..2bdffba --- /dev/null +++ b/features/productivity/lifecycle.feature @@ -0,0 +1,26 @@ +Feature: Creating lists and tasks + In order to perform my tasks one by one + As a user + I want to have an ability to see a list of tasks for my day + + Background: + Given there are users registered in system: + | email | password | + | adsam@example.com | my_password | + | john@example.com | my_password | + + Scenario: Creating list + Given I am signed in as "john@example.com" with password "password" + When I create new list "Work" + Then I can see list named "Work" + And I can't see any other list than list "Work" + And list "Work" has no tasks yet + When I create new task "Read emails" under "Work" list + When I create new task "Prepare Q1 report" under "Work" list + Then list "Work" has task "Read emails" assigned + And list "Work" has task "Prepare Q1 report" assigned + And task "Read emails" under list "Work" is not yet completed + And task "Prepare Q1 report" under list "Work" is not yet completed + When I mark task "Prepare Q1 report" under list "Work" as completed + And task "Prepare Q1 report" under list "Work" is completed + But task "Read emails" under list "Work" is not yet completed diff --git a/src/Productivity/Infrastructure/Behat/DomainContext.php b/src/Productivity/Infrastructure/Behat/DomainContext.php new file mode 100644 index 0000000..0501006 --- /dev/null +++ b/src/Productivity/Infrastructure/Behat/DomainContext.php @@ -0,0 +1,114 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Productivity\Infrastructure\Behat; + +use Behat\Behat\Context\Context; +use Behat\Behat\Tester\Exception\PendingException; +use Behat\Gherkin\Node\TableNode; + +/** + * @author Alan Gabriel Bem + * + * @codeCoverageIgnore + */ +final class DomainContext implements Context +{ + /** + * @Given I am signed in as :email with password :password + */ + public function iAmSignedInWithEmailAndPassword(string $email, string $password) : void + { + throw new PendingException(); + } + + /** + * @When I create new list :name + */ + public function iCreateNewList(string $name) : void + { + throw new PendingException(); + } + + /** + * @Then I can see list named :name + */ + public function iCanSeeListNamed(string $name) : void + { + throw new PendingException(); + } + + /** + * @Then list :name has no tasks yet + */ + public function listHasNoTasksYet(string $name) : void + { + throw new PendingException(); + } + + /** + * @When I create new task :task under :list list + */ + public function iCreateNewTaskUnderList(string $task, string $list) : void + { + throw new PendingException(); + } + + /** + * @Then list :list has task :task assigned + */ + public function listHasTaskAssigned(string $list, string $task) : void + { + throw new PendingException(); + } + + /** + * @Then task :task under list :list is not yet completed + */ + public function taskUnderListIsNotYetCompleted(string $task, string $list) : void + { + throw new PendingException(); + } + + /** + * @When I mark task :task under list :list as completed + */ + public function iMarkTaskUnderListAsCompleted(string $task, string $list) : void + { + throw new PendingException(); + } + + /** + * @When task :task under list :list is completed + */ + public function taskUnderListIsCompleted(string $task, string $list) : void + { + throw new PendingException(); + } + + /** + * @Given there are users registered in system: + */ + public function thereAreUsersRegisteredInSystem(TableNode $users) + { + throw new PendingException(); + } + + /** + * @Then I can't see any other list than list :name + */ + public function iCantSeeAnyOtherListThanList($name) + { + throw new PendingException(); + } +} diff --git a/src/Productivity/Infrastructure/Behat/RestContext.php b/src/Productivity/Infrastructure/Behat/RestContext.php new file mode 100644 index 0000000..e13612f --- /dev/null +++ b/src/Productivity/Infrastructure/Behat/RestContext.php @@ -0,0 +1,114 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Productivity\Infrastructure\Behat; + +use Behat\Behat\Context\Context; +use Behat\Behat\Tester\Exception\PendingException; +use Behat\Gherkin\Node\TableNode; + +/** + * @author Alan Gabriel Bem + * + * @codeCoverageIgnore + */ +final class RestContext implements Context +{ + /** + * @Given I am signed in as :email with password :password + */ + public function iAmSignedInWithEmailAndPassword(string $email, string $password) : void + { + throw new PendingException(); + } + + /** + * @When I create new list :name + */ + public function iCreateNewList(string $name) : void + { + throw new PendingException(); + } + + /** + * @Then I can see list named :name + */ + public function iCanSeeListNamed(string $name) : void + { + throw new PendingException(); + } + + /** + * @Then list :name has no tasks yet + */ + public function listHasNoTasksYet(string $name) : void + { + throw new PendingException(); + } + + /** + * @When I create new task :task under :list list + */ + public function iCreateNewTaskUnderList(string $task, string $list) : void + { + throw new PendingException(); + } + + /** + * @Then list :list has task :task assigned + */ + public function listHasTaskAssigned(string $list, string $task) : void + { + throw new PendingException(); + } + + /** + * @Then task :task under list :list is not yet completed + */ + public function taskUnderListIsNotYetCompleted(string $task, string $list) : void + { + throw new PendingException(); + } + + /** + * @When I mark task :task under list :list as completed + */ + public function iMarkTaskUnderListAsCompleted(string $task, string $list) : void + { + throw new PendingException(); + } + + /** + * @When task :task under list :list is completed + */ + public function taskUnderListIsCompleted(string $task, string $list) : void + { + throw new PendingException(); + } + + /** + * @Given there are users registered in system: + */ + public function thereAreUsersRegisteredInSystem(TableNode $users) + { + throw new PendingException(); + } + + /** + * @Then I can't see any other list than list :name + */ + public function iCantSeeAnyOtherListThanList($name) + { + throw new PendingException(); + } +} diff --git a/src/Shared/Infrastructure/Behat/StreakContext.php b/src/Shared/Infrastructure/Behat/StreakContext.php new file mode 100644 index 0000000..5a9088c --- /dev/null +++ b/src/Shared/Infrastructure/Behat/StreakContext.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Shared\Infrastructure\Behat; + +use Behat\Behat\Context\Context; +use Streak\Domain\Event\Subscription; +use Streak\Domain\EventStore; + +/** + * @author Alan Gabriel Bem + * + * @codeCoverageIgnore + */ +final class StreakContext implements Context +{ + private Subscription\Repository $subscriptions; + private EventStore $store; + + public function __construct(Subscription\Repository $subscriptions, EventStore $store) + { + $this->subscriptions = $subscriptions; + $this->store = $store; + } + + /** + * @BeforeScenario + */ + public function restartSubscriptions() : void + { + $filter = Subscription\Repository\Filter::nothing()->ignoreCompletedSubscriptions(); + $subscriptions = $this->subscriptions->all($filter); + + foreach ($subscriptions as $subscription) { + $subscription->restart(); + } + } + + /** + * @AfterStep + */ + public function runSubscriptions() : void + { + do { + $filter = Subscription\Repository\Filter::nothing()->ignoreCompletedSubscriptions(); + $subscriptions = $this->subscriptions->all($filter); + $processed = []; + foreach ($subscriptions as $index => $subscription) { + foreach ($subscription->subscribeTo($this->store) as $event) { + $processed[] = $event; + } + } + } while (0 !== count($processed)); // process subscriptions until no more events are left + } +} diff --git a/symfony.lock b/symfony.lock index 938ade6..f820188 100644 --- a/symfony.lock +++ b/symfony.lock @@ -16,6 +16,15 @@ "src/Entity/.gitignore" ] }, + "behat/behat": { + "version": "v3.8.1" + }, + "behat/gherkin": { + "version": "v4.8.0" + }, + "behat/transliterator": { + "version": "v1.3.0" + }, "brick/math": { "version": "0.9.2" }, @@ -117,6 +126,21 @@ "fig/link-util": { "version": "1.1.2" }, + "friends-of-behat/symfony-extension": { + "version": "2.0", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "master", + "version": "2.0", + "ref": "3d21344765fd3440a85bdd27d4cada186ec628bd" + }, + "files": [ + "behat.yml.dist", + "config/services_test.yaml", + "features/demo.feature", + "tests/Behat/DemoContext.php" + ] + }, "friendsofphp/php-cs-fixer": { "version": "3.0", "recipe": { @@ -641,6 +665,19 @@ "symfony/string": { "version": "v5.2.4" }, + "symfony/translation": { + "version": "3.3", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "3.3", + "ref": "2ad9d2545bce8ca1a863e50e92141f0b9d87ffcd" + }, + "files": [ + "config/packages/translation.yaml", + "translations/.gitignore" + ] + }, "symfony/translation-contracts": { "version": "v2.3.0" }, diff --git a/translations/.gitignore b/translations/.gitignore new file mode 100644 index 0000000..e69de29 From 9fdec39c87c7942c7ce4dba93718ad87bc139d0a Mon Sep 17 00:00:00 2001 From: Alan Gabriel Bem Date: Tue, 6 Apr 2021 07:13:52 +0200 Subject: [PATCH 2/4] added bin/behat --strict --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 820ac9a..4873ed2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -124,4 +124,4 @@ jobs: - name: Install dependencies run: docker-compose run --rm --no-deps php composer install --no-scripts --no-interaction --optimize-autoloader --ansi - name: Run behat - run: docker-compose run --rm php xphp bin/behat --format=progress + run: docker-compose run --rm php xphp bin/behat --format=progress --no-interaction --colors --strict From 7670403f9febdcd0cf1a6e6acd006a540783981b Mon Sep 17 00:00:00 2001 From: Alan Gabriel Bem Date: Sat, 14 Aug 2021 19:23:47 +0200 Subject: [PATCH 3/4] updated behat --- .github/workflows/ci.yaml | 2 +- composer.json | 2 + composer.lock | 363 +++++++++++++++++++++++++++++++++++++- symfony.lock | 6 +- 4 files changed, 368 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4873ed2..c7efe97 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -124,4 +124,4 @@ jobs: - name: Install dependencies run: docker-compose run --rm --no-deps php composer install --no-scripts --no-interaction --optimize-autoloader --ansi - name: Run behat - run: docker-compose run --rm php xphp bin/behat --format=progress --no-interaction --colors --strict + run: docker-compose run --rm php bin/behat --format=progress --no-interaction --colors --strict diff --git a/composer.json b/composer.json index 3802fe5..baff40c 100644 --- a/composer.json +++ b/composer.json @@ -42,6 +42,8 @@ "webmozart/assert": "^1.10" }, "require-dev": { + "behat/behat": "^3.8", + "friends-of-behat/symfony-extension": "^2.2", "friendsofphp/php-cs-fixer": "^3.0", "phpunit/phpunit": "^9.5", "qossmic/deptrac-shim": "^0.12.0", diff --git a/composer.lock b/composer.lock index 2a48c19..595780c 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": "e41c9b7f6b4e41f6d537e9d477d8eed4", + "content-hash": "eff8633a8252391ee02c2deb87637b97", "packages": [ { "name": "api-platform/core", @@ -8529,6 +8529,203 @@ } ], "packages-dev": [ + { + "name": "behat/behat", + "version": "v3.8.1", + "source": { + "type": "git", + "url": "https://github.com/Behat/Behat.git", + "reference": "fbb065457d523d9856d4b50775b4151a7598b510" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Behat/Behat/zipball/fbb065457d523d9856d4b50775b4151a7598b510", + "reference": "fbb065457d523d9856d4b50775b4151a7598b510", + "shasum": "" + }, + "require": { + "behat/gherkin": "^4.6.0", + "behat/transliterator": "^1.2", + "ext-mbstring": "*", + "php": "^7.2 || ^8.0", + "psr/container": "^1.0", + "symfony/config": "^4.4 || ^5.0", + "symfony/console": "^4.4 || ^5.0", + "symfony/dependency-injection": "^4.4 || ^5.0", + "symfony/event-dispatcher": "^4.4 || ^5.0", + "symfony/translation": "^4.4 || ^5.0", + "symfony/yaml": "^4.4 || ^5.0" + }, + "require-dev": { + "container-interop/container-interop": "^1.2", + "herrera-io/box": "~1.6.1", + "phpunit/phpunit": "^8.5 || ^9.0", + "symfony/process": "^4.4 || ^5.0" + }, + "suggest": { + "ext-dom": "Needed to output test results in JUnit format." + }, + "bin": [ + "bin/behat" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.8.x-dev" + } + }, + "autoload": { + "psr-4": { + "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.8.1" + }, + "time": "2020-11-07T15:55:18+00:00" + }, + { + "name": "behat/gherkin", + "version": "v4.8.0", + "source": { + "type": "git", + "url": "https://github.com/Behat/Gherkin.git", + "reference": "2391482cd003dfdc36b679b27e9f5326bd656acd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Behat/Gherkin/zipball/2391482cd003dfdc36b679b27e9f5326bd656acd", + "reference": "2391482cd003dfdc36b679b27e9f5326bd656acd", + "shasum": "" + }, + "require": { + "php": "~7.2|~8.0" + }, + "require-dev": { + "cucumber/cucumber": "dev-gherkin-16.0.0", + "phpunit/phpunit": "~8|~9", + "symfony/phpunit-bridge": "~3|~4|~5", + "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.4-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.8.0" + }, + "time": "2021-02-04T12:44:21+00:00" + }, + { + "name": "behat/transliterator", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/Behat/Transliterator.git", + "reference": "3c4ec1d77c3d05caa1f0bf8fb3aae4845005c7fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Behat/Transliterator/zipball/3c4ec1d77c3d05caa1f0bf8fb3aae4845005c7fc", + "reference": "3c4ec1d77c3d05caa1f0bf8fb3aae4845005c7fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "chuyskywalker/rolling-curl": "^3.1", + "php-yaoi/php-yaoi": "^1.0", + "phpunit/phpunit": "^4.8.36|^6.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-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.3.0" + }, + "time": "2020-01-14T16:39:13+00:00" + }, { "name": "composer/semver", "version": "3.2.5", @@ -8803,6 +9000,75 @@ ], "time": "2020-08-30T12:17:03+00:00" }, + { + "name": "friends-of-behat/symfony-extension", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfBehat/SymfonyExtension.git", + "reference": "9954f5d4c34d5522ded781ba62b07e06fa71bd10" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfBehat/SymfonyExtension/zipball/9954f5d4c34d5522ded781ba62b07e06fa71bd10", + "reference": "9954f5d4c34d5522ded781ba62b07e06fa71bd10", + "shasum": "" + }, + "require": { + "behat/behat": "^3.6.1", + "php": "^7.3 || ^8.0", + "symfony/dependency-injection": "^4.4 || ^5.1", + "symfony/http-kernel": "^4.4 || ^5.1", + "symfony/proxy-manager-bridge": "^4.4 || ^5.1" + }, + "require-dev": { + "behat/mink-selenium2-driver": "^1.3", + "friends-of-behat/mink": "^1.9", + "friends-of-behat/mink-browserkit-driver": "^1.5", + "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": "^3.2", + "symfony/browser-kit": "^4.4 || ^5.1", + "symfony/framework-bundle": "^4.4 || ^5.1", + "symfony/process": "^4.4 || ^5.1", + "symfony/yaml": "^4.4 || ^5.1", + "vimeo/psalm": "4.4.1" + }, + "suggest": { + "friends-of-behat/mink": "^1.9", + "friends-of-behat/mink-browserkit-driver": "^1.5", + "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.2.0" + }, + "time": "2021-02-04T15:45:42+00:00" + }, { "name": "friendsofphp/php-cs-fixer", "version": "v3.0.2", @@ -12293,6 +12559,101 @@ ], "time": "2021-07-23T15:54:19+00:00" }, + { + "name": "symfony/translation", + "version": "v5.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation.git", + "reference": "d89ad7292932c2699cbe4af98d72c5c6bbc504c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation/zipball/d89ad7292932c2699cbe4af98d72c5c6bbc504c1", + "reference": "d89ad7292932c2699cbe4af98d72c5c6bbc504c1", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.16", + "symfony/translation-contracts": "^2.3" + }, + "conflict": { + "symfony/config": "<4.4", + "symfony/dependency-injection": "<5.0", + "symfony/http-kernel": "<5.0", + "symfony/twig-bundle": "<5.0", + "symfony/yaml": "<4.4" + }, + "provide": { + "symfony/translation-implementation": "2.3" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/dependency-injection": "^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/http-kernel": "^5.0", + "symfony/intl": "^4.4|^5.0", + "symfony/polyfill-intl-icu": "^1.21", + "symfony/service-contracts": "^1.1.2|^2", + "symfony/yaml": "^4.4|^5.0" + }, + "suggest": { + "psr/log-implementation": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools to internationalize your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/translation/tree/v5.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-25T09:39:16+00:00" + }, { "name": "symfony/web-profiler-bundle", "version": "v5.3.5", diff --git a/symfony.lock b/symfony.lock index f820188..a97a8de 100644 --- a/symfony.lock +++ b/symfony.lock @@ -666,12 +666,12 @@ "version": "v5.2.4" }, "symfony/translation": { - "version": "3.3", + "version": "5.3", "recipe": { "repo": "github.com/symfony/recipes", "branch": "master", - "version": "3.3", - "ref": "2ad9d2545bce8ca1a863e50e92141f0b9d87ffcd" + "version": "5.3", + "ref": "da64f5a2b6d96f5dc24914517c0350a5f91dee43" }, "files": [ "config/packages/translation.yaml", From 119ea0c677ce17dd87d77f6435092d0392ba2d23 Mon Sep 17 00:00:00 2001 From: Alan Gabriel Bem Date: Sat, 14 Aug 2021 22:00:06 +0200 Subject: [PATCH 4/4] working behat skeleton --- .github/workflows/ci.yaml | 26 ++++++++++++++++--- behat.yml.dist | 1 - .../Infrastructure/Behat/DomainContext.php | 16 ++---------- .../Infrastructure/Behat/RestContext.php | 16 ++---------- .../Infrastructure/Behat/StreakContext.php | 4 +-- 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c7efe97..142b49b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -105,8 +105,8 @@ jobs: run: docker-compose run --rm --no-deps php composer install --no-scripts --no-interaction --optimize-autoloader --ansi - name: Run deptrac run: docker-compose run --rm --no-deps php bin/deptrac --no-progress --no-interaction --cache-file=./build/.deptrac/.deptrac.cache --ansi - run-behat: - name: behat + run-behat-domain: + name: behat (domain) runs-on: ubuntu-latest steps: - name: Checkout repository @@ -124,4 +124,24 @@ jobs: - name: Install dependencies run: docker-compose run --rm --no-deps php composer install --no-scripts --no-interaction --optimize-autoloader --ansi - name: Run behat - run: docker-compose run --rm php bin/behat --format=progress --no-interaction --colors --strict + run: docker-compose run --rm php bin/behat --suite=domain --format=progress --no-interaction --colors --strict + run-behat-rest: + name: behat (REST) + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Docker pull + run: docker-compose pull php + # - name: Docker build + # run: docker-compose build --force-rm + - name: Composer caching + uses: actions/cache@v2 + with: + path: ./build/.composer + key: ${{ runner.os }}-composer-v1-${{ hashFiles('composer.lock') }} + restore-keys: ${{ runner.os }}-composer-v1- + - name: Install dependencies + run: docker-compose run --rm --no-deps php composer install --no-scripts --no-interaction --optimize-autoloader --ansi + - name: Run behat + run: docker-compose run --rm php bin/behat --suite=rest --format=progress --no-interaction --colors --strict diff --git a/behat.yml.dist b/behat.yml.dist index ada2e4f..0ea1d6e 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -5,7 +5,6 @@ default: - features/productivity contexts: - Productivity\Infrastructure\Behat\DomainContext - - Shared\Infrastructure\Behat\StreakContext rest: paths: - features/productivity diff --git a/src/Productivity/Infrastructure/Behat/DomainContext.php b/src/Productivity/Infrastructure/Behat/DomainContext.php index 0501006..52d7674 100644 --- a/src/Productivity/Infrastructure/Behat/DomainContext.php +++ b/src/Productivity/Infrastructure/Behat/DomainContext.php @@ -14,7 +14,6 @@ namespace Productivity\Infrastructure\Behat; use Behat\Behat\Context\Context; -use Behat\Behat\Tester\Exception\PendingException; use Behat\Gherkin\Node\TableNode; /** @@ -29,7 +28,6 @@ final class DomainContext implements Context */ public function iAmSignedInWithEmailAndPassword(string $email, string $password) : void { - throw new PendingException(); } /** @@ -37,7 +35,6 @@ public function iAmSignedInWithEmailAndPassword(string $email, string $password) */ public function iCreateNewList(string $name) : void { - throw new PendingException(); } /** @@ -45,7 +42,6 @@ public function iCreateNewList(string $name) : void */ public function iCanSeeListNamed(string $name) : void { - throw new PendingException(); } /** @@ -53,7 +49,6 @@ public function iCanSeeListNamed(string $name) : void */ public function listHasNoTasksYet(string $name) : void { - throw new PendingException(); } /** @@ -61,7 +56,6 @@ public function listHasNoTasksYet(string $name) : void */ public function iCreateNewTaskUnderList(string $task, string $list) : void { - throw new PendingException(); } /** @@ -69,7 +63,6 @@ public function iCreateNewTaskUnderList(string $task, string $list) : void */ public function listHasTaskAssigned(string $list, string $task) : void { - throw new PendingException(); } /** @@ -77,7 +70,6 @@ public function listHasTaskAssigned(string $list, string $task) : void */ public function taskUnderListIsNotYetCompleted(string $task, string $list) : void { - throw new PendingException(); } /** @@ -85,7 +77,6 @@ public function taskUnderListIsNotYetCompleted(string $task, string $list) : voi */ public function iMarkTaskUnderListAsCompleted(string $task, string $list) : void { - throw new PendingException(); } /** @@ -93,22 +84,19 @@ public function iMarkTaskUnderListAsCompleted(string $task, string $list) : void */ public function taskUnderListIsCompleted(string $task, string $list) : void { - throw new PendingException(); } /** * @Given there are users registered in system: */ - public function thereAreUsersRegisteredInSystem(TableNode $users) + public function thereAreUsersRegisteredInSystem(TableNode $users) : void { - throw new PendingException(); } /** * @Then I can't see any other list than list :name */ - public function iCantSeeAnyOtherListThanList($name) + public function iCantSeeAnyOtherListThanList($name) : void { - throw new PendingException(); } } diff --git a/src/Productivity/Infrastructure/Behat/RestContext.php b/src/Productivity/Infrastructure/Behat/RestContext.php index e13612f..d8a2204 100644 --- a/src/Productivity/Infrastructure/Behat/RestContext.php +++ b/src/Productivity/Infrastructure/Behat/RestContext.php @@ -14,7 +14,6 @@ namespace Productivity\Infrastructure\Behat; use Behat\Behat\Context\Context; -use Behat\Behat\Tester\Exception\PendingException; use Behat\Gherkin\Node\TableNode; /** @@ -29,7 +28,6 @@ final class RestContext implements Context */ public function iAmSignedInWithEmailAndPassword(string $email, string $password) : void { - throw new PendingException(); } /** @@ -37,7 +35,6 @@ public function iAmSignedInWithEmailAndPassword(string $email, string $password) */ public function iCreateNewList(string $name) : void { - throw new PendingException(); } /** @@ -45,7 +42,6 @@ public function iCreateNewList(string $name) : void */ public function iCanSeeListNamed(string $name) : void { - throw new PendingException(); } /** @@ -53,7 +49,6 @@ public function iCanSeeListNamed(string $name) : void */ public function listHasNoTasksYet(string $name) : void { - throw new PendingException(); } /** @@ -61,7 +56,6 @@ public function listHasNoTasksYet(string $name) : void */ public function iCreateNewTaskUnderList(string $task, string $list) : void { - throw new PendingException(); } /** @@ -69,7 +63,6 @@ public function iCreateNewTaskUnderList(string $task, string $list) : void */ public function listHasTaskAssigned(string $list, string $task) : void { - throw new PendingException(); } /** @@ -77,7 +70,6 @@ public function listHasTaskAssigned(string $list, string $task) : void */ public function taskUnderListIsNotYetCompleted(string $task, string $list) : void { - throw new PendingException(); } /** @@ -85,7 +77,6 @@ public function taskUnderListIsNotYetCompleted(string $task, string $list) : voi */ public function iMarkTaskUnderListAsCompleted(string $task, string $list) : void { - throw new PendingException(); } /** @@ -93,22 +84,19 @@ public function iMarkTaskUnderListAsCompleted(string $task, string $list) : void */ public function taskUnderListIsCompleted(string $task, string $list) : void { - throw new PendingException(); } /** * @Given there are users registered in system: */ - public function thereAreUsersRegisteredInSystem(TableNode $users) + public function thereAreUsersRegisteredInSystem(TableNode $users) : void { - throw new PendingException(); } /** * @Then I can't see any other list than list :name */ - public function iCantSeeAnyOtherListThanList($name) + public function iCantSeeAnyOtherListThanList($name) : void { - throw new PendingException(); } } diff --git a/src/Shared/Infrastructure/Behat/StreakContext.php b/src/Shared/Infrastructure/Behat/StreakContext.php index 5a9088c..f157fa9 100644 --- a/src/Shared/Infrastructure/Behat/StreakContext.php +++ b/src/Shared/Infrastructure/Behat/StreakContext.php @@ -55,11 +55,11 @@ public function runSubscriptions() : void $filter = Subscription\Repository\Filter::nothing()->ignoreCompletedSubscriptions(); $subscriptions = $this->subscriptions->all($filter); $processed = []; - foreach ($subscriptions as $index => $subscription) { + foreach ($subscriptions as $subscription) { foreach ($subscription->subscribeTo($this->store) as $event) { $processed[] = $event; } } - } while (0 !== count($processed)); // process subscriptions until no more events are left + } while (0 !== \count($processed)); // process subscriptions until no more events are left } }