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..142b49b 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,43 @@ 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-domain: + name: behat (domain) + 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=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/.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..0ea1d6e --- /dev/null +++ b/behat.yml.dist @@ -0,0 +1,21 @@ +default: + suites: + domain: + paths: + - features/productivity + contexts: + - Productivity\Infrastructure\Behat\DomainContext + 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/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/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..52d7674 --- /dev/null +++ b/src/Productivity/Infrastructure/Behat/DomainContext.php @@ -0,0 +1,102 @@ + + * + * 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\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 + { + } + + /** + * @When I create new list :name + */ + public function iCreateNewList(string $name) : void + { + } + + /** + * @Then I can see list named :name + */ + public function iCanSeeListNamed(string $name) : void + { + } + + /** + * @Then list :name has no tasks yet + */ + public function listHasNoTasksYet(string $name) : void + { + } + + /** + * @When I create new task :task under :list list + */ + public function iCreateNewTaskUnderList(string $task, string $list) : void + { + } + + /** + * @Then list :list has task :task assigned + */ + public function listHasTaskAssigned(string $list, string $task) : void + { + } + + /** + * @Then task :task under list :list is not yet completed + */ + public function taskUnderListIsNotYetCompleted(string $task, string $list) : void + { + } + + /** + * @When I mark task :task under list :list as completed + */ + public function iMarkTaskUnderListAsCompleted(string $task, string $list) : void + { + } + + /** + * @When task :task under list :list is completed + */ + public function taskUnderListIsCompleted(string $task, string $list) : void + { + } + + /** + * @Given there are users registered in system: + */ + public function thereAreUsersRegisteredInSystem(TableNode $users) : void + { + } + + /** + * @Then I can't see any other list than list :name + */ + public function iCantSeeAnyOtherListThanList($name) : void + { + } +} diff --git a/src/Productivity/Infrastructure/Behat/RestContext.php b/src/Productivity/Infrastructure/Behat/RestContext.php new file mode 100644 index 0000000..d8a2204 --- /dev/null +++ b/src/Productivity/Infrastructure/Behat/RestContext.php @@ -0,0 +1,102 @@ + + * + * 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\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 + { + } + + /** + * @When I create new list :name + */ + public function iCreateNewList(string $name) : void + { + } + + /** + * @Then I can see list named :name + */ + public function iCanSeeListNamed(string $name) : void + { + } + + /** + * @Then list :name has no tasks yet + */ + public function listHasNoTasksYet(string $name) : void + { + } + + /** + * @When I create new task :task under :list list + */ + public function iCreateNewTaskUnderList(string $task, string $list) : void + { + } + + /** + * @Then list :list has task :task assigned + */ + public function listHasTaskAssigned(string $list, string $task) : void + { + } + + /** + * @Then task :task under list :list is not yet completed + */ + public function taskUnderListIsNotYetCompleted(string $task, string $list) : void + { + } + + /** + * @When I mark task :task under list :list as completed + */ + public function iMarkTaskUnderListAsCompleted(string $task, string $list) : void + { + } + + /** + * @When task :task under list :list is completed + */ + public function taskUnderListIsCompleted(string $task, string $list) : void + { + } + + /** + * @Given there are users registered in system: + */ + public function thereAreUsersRegisteredInSystem(TableNode $users) : void + { + } + + /** + * @Then I can't see any other list than list :name + */ + public function iCantSeeAnyOtherListThanList($name) : void + { + } +} diff --git a/src/Shared/Infrastructure/Behat/StreakContext.php b/src/Shared/Infrastructure/Behat/StreakContext.php new file mode 100644 index 0000000..f157fa9 --- /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 $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..a97a8de 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": "5.3", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "5.3", + "ref": "da64f5a2b6d96f5dc24914517c0350a5f91dee43" + }, + "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