From 6b21ab1a17512640ef37ce403221d6d2a23886a8 Mon Sep 17 00:00:00 2001 From: "tien.xuan.vo" Date: Fri, 22 Dec 2023 15:30:48 +0700 Subject: [PATCH] test(compatibility-suite): Implement V2 scenarios --- .github/workflows/compatibility-suite.yml | 16 +++++++++ behat.yml | 2 ++ .../suites/v2/http/consumer.yml | 29 +++++++++++++++ .../suites/v2/http/provider.yml | 30 ++++++++++++++++ .../tests/Context/V2/Http/ConsumerContext.php | 36 +++++++++++++++++++ .../tests/ServiceContainer/V2.php | 11 ++++++ 6 files changed, 124 insertions(+) create mode 100644 compatibility-suite/suites/v2/http/consumer.yml create mode 100644 compatibility-suite/suites/v2/http/provider.yml create mode 100644 compatibility-suite/tests/Context/V2/Http/ConsumerContext.php create mode 100644 compatibility-suite/tests/ServiceContainer/V2.php diff --git a/.github/workflows/compatibility-suite.yml b/.github/workflows/compatibility-suite.yml index 366c7077..38c017ba 100644 --- a/.github/workflows/compatibility-suite.yml +++ b/.github/workflows/compatibility-suite.yml @@ -22,3 +22,19 @@ jobs: - name: Run Behat run: vendor/bin/behat compatibility-suite/pact-compatibility-suite/features/V1 + v2: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + coverage: none + + - uses: ramsey/composer-install@v2 + + - name: Run Behat + run: vendor/bin/behat compatibility-suite/pact-compatibility-suite/features/V2 diff --git a/behat.yml b/behat.yml index 6ff7b709..e2cb9df0 100644 --- a/behat.yml +++ b/behat.yml @@ -1,3 +1,5 @@ imports: - 'compatibility-suite/suites/v1/http/consumer.yml' - 'compatibility-suite/suites/v1/http/provider.yml' + - 'compatibility-suite/suites/v2/http/consumer.yml' + - 'compatibility-suite/suites/v2/http/provider.yml' diff --git a/compatibility-suite/suites/v2/http/consumer.yml b/compatibility-suite/suites/v2/http/consumer.yml new file mode 100644 index 00000000..e6872644 --- /dev/null +++ b/compatibility-suite/suites/v2/http/consumer.yml @@ -0,0 +1,29 @@ +default: + suites: + v2_http_consumer: + paths: [ '%paths.base%/compatibility-suite/pact-compatibility-suite/features/V2/http_consumer.feature' ] + + contexts: + - 'PhpPactTest\CompatibilitySuite\Context\Shared\Hook\SetUpContext' + - 'PhpPactTest\CompatibilitySuite\Context\Shared\InteractionsContext': + - '@interactions_storage' + - '@request_matching_rule_builder' + - '@response_matching_rule_builder' + - '@matching_rules_storage' + - 'PhpPactTest\CompatibilitySuite\Context\Shared\Transform\InteractionsContext': + - '@interaction_builder' + - '@matching_rules_storage' + - 'PhpPactTest\CompatibilitySuite\Context\V1\Http\ConsumerContext': + - '@server' + - '@request_builder' + - '@client' + - '@interactions_storage' + - '@fixture_loader' + - 'PhpPactTest\CompatibilitySuite\Context\V2\Http\ConsumerContext': + - '@server' + - '@request_builder' + - '@request_matching_rule_builder' + - '@matching_rules_storage' + - '@interactions_storage' + + services: PhpPactTest\CompatibilitySuite\ServiceContainer\V2 diff --git a/compatibility-suite/suites/v2/http/provider.yml b/compatibility-suite/suites/v2/http/provider.yml new file mode 100644 index 00000000..124d6b47 --- /dev/null +++ b/compatibility-suite/suites/v2/http/provider.yml @@ -0,0 +1,30 @@ +default: + suites: + v2_http_provider: + paths: [ '%paths.base%/compatibility-suite/pact-compatibility-suite/features/V2/http_provider.feature' ] + + contexts: + - 'PhpPactTest\CompatibilitySuite\Context\Shared\Hook\SetUpContext' + - 'PhpPactTest\CompatibilitySuite\Context\Shared\InteractionsContext': + - '@interactions_storage' + - '@request_matching_rule_builder' + - '@response_matching_rule_builder' + - '@matching_rules_storage' + - 'PhpPactTest\CompatibilitySuite\Context\Shared\Transform\InteractionsContext': + - '@interaction_builder' + - '@matching_rules_storage' + - 'PhpPactTest\CompatibilitySuite\Context\Shared\Hook\ProviderStateContext': + - '@provider_state_server' + - 'PhpPactTest\CompatibilitySuite\Context\Shared\ProviderContext': + - '@server' + - '@provider_verifier' + - '@provider_state_server' + - 'PhpPactTest\CompatibilitySuite\Context\V1\Http\ProviderContext': + - '@server' + - '@pact_writer' + - '@pact_broker' + - '@response_builder' + - '@interactions_storage' + - '@provider_verifier' + + services: PhpPactTest\CompatibilitySuite\ServiceContainer\V2 diff --git a/compatibility-suite/tests/Context/V2/Http/ConsumerContext.php b/compatibility-suite/tests/Context/V2/Http/ConsumerContext.php new file mode 100644 index 00000000..ae9ee49f --- /dev/null +++ b/compatibility-suite/tests/Context/V2/Http/ConsumerContext.php @@ -0,0 +1,36 @@ +storage->get(InteractionsStorageInterface::SERVER_DOMAIN, $id)->getRequest(); + $this->requestBuilder->build($request, $table->getHash()[0]); + if ($file = $this->matchingRulesStorage->get(MatchingRulesStorageInterface::REQUEST_DOMAIN, $id)) { + $this->requestMatchingRuleBuilder->build($request, $file); + } + $this->server->register($id); + } +} diff --git a/compatibility-suite/tests/ServiceContainer/V2.php b/compatibility-suite/tests/ServiceContainer/V2.php new file mode 100644 index 00000000..a4107cc7 --- /dev/null +++ b/compatibility-suite/tests/ServiceContainer/V2.php @@ -0,0 +1,11 @@ +