-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #430 from tienvx/v2-http-consumer-provider
test(compatibility-suite): Implement V2 scenarios
- Loading branch information
Showing
6 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
36 changes: 36 additions & 0 deletions
36
compatibility-suite/tests/Context/V2/Http/ConsumerContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace PhpPactTest\CompatibilitySuite\Context\V2\Http; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Behat\Gherkin\Node\TableNode; | ||
use PhpPactTest\CompatibilitySuite\Service\InteractionsStorageInterface; | ||
use PhpPactTest\CompatibilitySuite\Service\MatchingRulesStorageInterface; | ||
use PhpPactTest\CompatibilitySuite\Service\RequestBuilderInterface; | ||
use PhpPactTest\CompatibilitySuite\Service\RequestMatchingRuleBuilderInterface; | ||
use PhpPactTest\CompatibilitySuite\Service\ServerInterface; | ||
|
||
final class ConsumerContext implements Context | ||
{ | ||
public function __construct( | ||
private ServerInterface $server, | ||
private RequestBuilderInterface $requestBuilder, | ||
private RequestMatchingRuleBuilderInterface $requestMatchingRuleBuilder, | ||
private MatchingRulesStorageInterface $matchingRulesStorage, | ||
private InteractionsStorageInterface $storage, | ||
) { | ||
} | ||
|
||
/** | ||
* @When the mock server is started with interaction :id but with the following changes: | ||
*/ | ||
public function theMockServerIsStartedWithInteractionButWithTheFollowingChanges(int $id, TableNode $table): void | ||
{ | ||
$request = $this->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace PhpPactTest\CompatibilitySuite\ServiceContainer; | ||
|
||
class V2 extends V1 | ||
{ | ||
protected function getSpecification(): string | ||
{ | ||
return '2.0.0'; | ||
} | ||
} |