Skip to content

Commit

Permalink
Merge pull request #52 from tienvx/rename-test-handler
Browse files Browse the repository at this point in the history
chore: Rename test handler
  • Loading branch information
tienvx authored Mar 30, 2024
2 parents f4f50ef + 0d0eab3 commit a7164c7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions tests/Application/Controller/MessagesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ public function testInvalidProviderStateParams(): void
'description' => 'has message',
'providerStates' => [
[
'name' => 'required state',
'name' => 'has values',
'params' => 123,
],
],
]));
$this->assertResponseStatusCodeSame(400);
$this->assertStringContainsString("Invalid 'params' for provider state 'required state'.", $client->getResponse()->getContent());
$this->assertStringContainsString("Invalid 'params' for provider state 'has values'.", $client->getResponse()->getContent());
}

public function testMissingDescription(): void
Expand All @@ -108,7 +108,7 @@ public function testMissingDescription(): void
$client->request('POST', '/test-pact-messages', [], [], [], json_encode([
'providerStates' => [
[
'name' => 'required state',
'name' => 'has values',
'params' => [
'key' => 'value',
],
Expand All @@ -126,7 +126,7 @@ public function testNoMessage(): void
'description' => 'no message',
'providerStates' => [
[
'name' => 'required state',
'name' => 'has values',
'params' => [
'key' => 'value',
],
Expand All @@ -145,7 +145,7 @@ public function testHasMessage(): void
'description' => 'has message',
'providerStates' => [
[
'name' => 'required state',
'name' => 'has values',
'params' => [
'key' => 'value',
],
Expand All @@ -155,6 +155,6 @@ public function testHasMessage(): void
$this->assertResponseStatusCodeSame(200);
$this->assertResponseHeaderSame('Content-Type', 'text/plain; charset=UTF-8');
$this->assertResponseHeaderSame('Pact-Message-Metadata', 'eyJrZXkiOiJ2YWx1ZSIsImNvbnRlbnRUeXBlIjoidGV4dFwvcGxhaW4ifQ==');
$this->assertStringContainsString('message content', $client->getResponse()->getContent());
$this->assertSame('message content', $client->getResponse()->getContent());
}
}
24 changes: 12 additions & 12 deletions tests/Application/Controller/StateChangeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testInvalidProviderStateParamsInBody(): void
{
$client = static::createClient();
$client->request('POST', '/test-pact-change-state', [], [], [], json_encode([
'state' => 'required state',
'state' => 'has values',
'params' => 123,
'action' => Action::SETUP,
]));
Expand All @@ -62,7 +62,7 @@ public function testMissingProviderStateActionInBody(): void
{
$client = static::createClient();
$client->request('POST', '/test-pact-change-state', [], [], [], json_encode([
'state' => 'required state',
'state' => 'has values',
'params' => [
'key' => 'value',
],
Expand All @@ -75,7 +75,7 @@ public function testInvalidProviderStateActionInBody(): void
{
$client = static::createClient();
$client->request('POST', '/test-pact-change-state', [], [], [], json_encode([
'state' => 'required state',
'state' => 'has values',
'params' => [
'key' => 'value',
],
Expand All @@ -87,7 +87,7 @@ public function testInvalidProviderStateActionInBody(): void

#[TestWith([Action::SETUP])]
#[TestWith([Action::TEARDOWN])]
public function testNoStateValuesWithBody(Action $action): void
public function testNoSValuesStateInBody(Action $action): void
{
$client = static::createClient();
$client->request('POST', '/test-pact-change-state', [], [], [], json_encode([
Expand All @@ -101,11 +101,11 @@ public function testNoStateValuesWithBody(Action $action): void
$this->assertEmpty($client->getResponse()->getContent());
}

public function testHasValuesWithBody(): void
public function testHasValuesStateInBody(): void
{
$client = static::createClient();
$client->request('POST', '/test-pact-change-state', [], [], [], json_encode([
'state' => 'required state',
'state' => 'has values',
'params' => [
'key' => 'value',
],
Expand All @@ -119,7 +119,7 @@ public function testHasValuesWithBody(): void
}

#[TestWith([[]])]
#[TestWith([['state[]' => 'required state']])]
#[TestWith([['state[]' => 'has values']])]
public function testMissingOrInvalidProviderStateNameInQuery(array $value): void
{
$_ENV['STATE_CHANGE_BODY'] = 'false';
Expand All @@ -138,7 +138,7 @@ public function testMissingProviderStateActionInQuery(): void
$_ENV['STATE_CHANGE_BODY'] = 'false';
$client = static::createClient();
$client->request('POST', '/test-pact-change-state?'.http_build_query([
'state' => 'required state',
'state' => 'has values',
'key' => 'value',
]));
$this->assertResponseStatusCodeSame(400);
Expand All @@ -150,7 +150,7 @@ public function testInvalidProviderStateActionInQuery(): void
$_ENV['STATE_CHANGE_BODY'] = 'false';
$client = static::createClient();
$client->request('POST', '/test-pact-change-state?'.http_build_query([
'state' => 'required state',
'state' => 'has values',
'key' => 'value',
'action' => 'clean',
]));
Expand All @@ -160,7 +160,7 @@ public function testInvalidProviderStateActionInQuery(): void

#[TestWith([Action::SETUP])]
#[TestWith([Action::TEARDOWN])]
public function testNoStateValuesWithoutBody(Action $action): void
public function testNoValuesStateInQuery(Action $action): void
{
$_ENV['STATE_CHANGE_BODY'] = 'false';
$client = static::createClient();
Expand All @@ -173,12 +173,12 @@ public function testNoStateValuesWithoutBody(Action $action): void
$this->assertEmpty($client->getResponse()->getContent());
}

public function testHasValuesWithoutBody(): void
public function testHasValuesStateInQuery(): void
{
$_ENV['STATE_CHANGE_BODY'] = 'false';
$client = static::createClient();
$client->request('POST', '/test-pact-change-state?'.http_build_query([
'state' => 'required state',
'state' => 'has values',
'key' => 'value',
'action' => Action::SETUP->value,
]));
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Service/StateHandlerManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class StateHandlerManagerTest extends KernelTestCase
{
#[TestWith(['no values', Action::SETUP, null])]
#[TestWith(['no values', Action::TEARDOWN, null])]
#[TestWith(['required state', Action::SETUP, new StateValues(['id' => 123])])]
#[TestWith(['required state', Action::TEARDOWN, null])]
#[TestWith(['has values', Action::SETUP, new StateValues(['id' => 123])])]
#[TestWith(['has values', Action::TEARDOWN, null])]
public function testHandle(string $state, Action $action, ?StateValues $stateValues): void
{
self::bootKernel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Tienvx\Bundle\PactProviderBundle\StateHandler\SetUpInterface;
use Tienvx\Bundle\PactProviderBundle\StateHandler\TearDownInterface;

#[AsStateHandler(state: 'required state')]
class RequiredStateHandler implements SetUpInterface, TearDownInterface
#[AsStateHandler(state: 'has values')]
class HasValuesHandler implements SetUpInterface, TearDownInterface
{
public function setUp(array $params): ?StateValues
{
Expand Down

0 comments on commit a7164c7

Please sign in to comment.