diff --git a/composer.lock b/composer.lock index f209da9..21d1c99 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "symfony/polyfill-ctype", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41" + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f4ba089a5b6366e453971d3aad5fe8e897b37f41", - "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", "shasum": "" }, "require": { @@ -29,7 +29,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -67,7 +67,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.0" }, "funding": [ { @@ -83,7 +83,7 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "webmozart/assert", @@ -142,16 +142,16 @@ "packages-dev": [ { "name": "amphp/amp", - "version": "v2.5.1", + "version": "v2.5.2", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "ecdc3c476b3ccff02f8e5d5bcc04f7ccfd18751c" + "reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/ecdc3c476b3ccff02f8e5d5bcc04f7ccfd18751c", - "reference": "ecdc3c476b3ccff02f8e5d5bcc04f7ccfd18751c", + "url": "https://api.github.com/repos/amphp/amp/zipball/efca2b32a7580087adb8aabbff6be1dc1bb924a9", + "reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9", "shasum": "" }, "require": { @@ -219,7 +219,7 @@ "support": { "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v2.5.1" + "source": "https://github.com/amphp/amp/tree/v2.5.2" }, "funding": [ { @@ -227,7 +227,7 @@ "type": "github" } ], - "time": "2020-11-03T16:23:45+00:00" + "time": "2021-01-10T17:06:37+00:00" }, { "name": "amphp/byte-stream", @@ -625,25 +625,25 @@ }, { "name": "felixfbecker/advanced-json-rpc", - "version": "v3.1.1", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", - "reference": "0ed363f8de17d284d479ec813c9ad3f6834b5c40" + "reference": "06f0b06043c7438959dbdeed8bb3f699a19be22e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/0ed363f8de17d284d479ec813c9ad3f6834b5c40", - "reference": "0ed363f8de17d284d479ec813c9ad3f6834b5c40", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/06f0b06043c7438959dbdeed8bb3f699a19be22e", + "reference": "06f0b06043c7438959dbdeed8bb3f699a19be22e", "shasum": "" }, "require": { "netresearch/jsonmapper": "^1.0 || ^2.0", - "php": ">=7.0", - "phpdocumentor/reflection-docblock": "^4.0.0 || ^5.0.0" + "php": "^7.1 || ^8.0", + "phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0.0" }, "require-dev": { - "phpunit/phpunit": "^6.0.0" + "phpunit/phpunit": "^7.0 || ^8.0" }, "type": "library", "autoload": { @@ -664,9 +664,9 @@ "description": "A more advanced JSONRPC implementation", "support": { "issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues", - "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/master" + "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.0" }, - "time": "2020-03-11T15:21:41+00:00" + "time": "2021-01-10T17:48:47+00:00" }, { "name": "felixfbecker/language-server-protocol", @@ -3902,16 +3902,16 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "c7cf3f858ec7d70b89559d6e6eb1f7c2517d479c" + "reference": "267a9adeb8ecb8071040a740930e077cdfb987af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/c7cf3f858ec7d70b89559d6e6eb1f7c2517d479c", - "reference": "c7cf3f858ec7d70b89559d6e6eb1f7c2517d479c", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/267a9adeb8ecb8071040a740930e077cdfb987af", + "reference": "267a9adeb8ecb8071040a740930e077cdfb987af", "shasum": "" }, "require": { @@ -3923,7 +3923,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3963,7 +3963,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.22.0" }, "funding": [ { @@ -3979,20 +3979,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "727d1096295d807c309fb01a851577302394c897" + "reference": "6e971c891537eb617a00bb07a43d182a6915faba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/727d1096295d807c309fb01a851577302394c897", - "reference": "727d1096295d807c309fb01a851577302394c897", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/6e971c891537eb617a00bb07a43d182a6915faba", + "reference": "6e971c891537eb617a00bb07a43d182a6915faba", "shasum": "" }, "require": { @@ -4004,7 +4004,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4047,7 +4047,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.22.0" }, "funding": [ { @@ -4063,20 +4063,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T17:09:11+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "39d483bdf39be819deabf04ec872eb0b2410b531" + "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531", - "reference": "39d483bdf39be819deabf04ec872eb0b2410b531", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", + "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", "shasum": "" }, "require": { @@ -4088,7 +4088,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4127,7 +4127,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.0" }, "funding": [ { @@ -4143,20 +4143,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "8ff431c517be11c78c48a39a66d37431e26a6bed" + "reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/8ff431c517be11c78c48a39a66d37431e26a6bed", - "reference": "8ff431c517be11c78c48a39a66d37431e26a6bed", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/a678b42e92f86eca04b7fa4c0f6f19d097fb69e2", + "reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2", "shasum": "" }, "require": { @@ -4165,7 +4165,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4206,7 +4206,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.22.0" }, "funding": [ { @@ -4222,20 +4222,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de" + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/e70aa8b064c5b72d3df2abd5ab1e90464ad009de", - "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dc3063ba22c2a1fd2f45ed856374d79114998f91", + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91", "shasum": "" }, "require": { @@ -4244,7 +4244,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4289,7 +4289,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.0" }, "funding": [ { @@ -4305,7 +4305,7 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/process", diff --git a/src/Definition/Body.php b/src/Definition/Body.php index 1cc1fbf..0f39bf5 100644 --- a/src/Definition/Body.php +++ b/src/Definition/Body.php @@ -8,13 +8,13 @@ final class Body { - private string $content; + private array $content; private MatchingRules $matchingRules; public static function fromArray(array $payload): self { Assert::keyExists($payload, 'content'); - Assert::string($payload['content']); + Assert::isArray($payload['content']); Assert::keyExists($payload, 'matching_rules'); Assert::isArray($payload['matching_rules']); @@ -32,7 +32,7 @@ public function toArray(): array ]; } - public function content(): string + public function content(): array { return $this->content; } @@ -42,7 +42,7 @@ public function matchingRules(): MatchingRules return $this->matchingRules; } - private function __construct(string $content, MatchingRules $matchingRules) + private function __construct(array $content, MatchingRules $matchingRules) { $this->content = $content; $this->matchingRules = $matchingRules; diff --git a/src/Definition/Consumer.php b/src/Definition/Consumer.php index 26c17f8..afab2de 100644 --- a/src/Definition/Consumer.php +++ b/src/Definition/Consumer.php @@ -25,6 +25,11 @@ public function toArray(): array ]; } + public function name(): string + { + return $this->name; + } + private function __construct(string $name) { $this->name = $name; diff --git a/src/Definition/Provider.php b/src/Definition/Provider.php index b3c2559..2a72fe5 100644 --- a/src/Definition/Provider.php +++ b/src/Definition/Provider.php @@ -25,6 +25,11 @@ public function toArray(): array ]; } + public function name(): string + { + return $this->name; + } + private function __construct(string $name) { $this->name = $name; diff --git a/src/Message/Message.php b/src/Message/Message.php index 5df5907..5da704f 100644 --- a/src/Message/Message.php +++ b/src/Message/Message.php @@ -8,18 +8,15 @@ final class Message { - private string $body; + private array $body; private array $headers; public static function fromMessageDefinition(MessageDefinition $messageDefinition): self { - return new self( - $messageDefinition->body()->content(), - $messageDefinition->metadata() - ); + return new self($messageDefinition->body()->content(), $messageDefinition->metadata()); } - public function body(): string + public function body(): array { return $this->body; } @@ -29,7 +26,7 @@ public function headers(): array return $this->headers; } - private function __construct(string $body, array $headers) + private function __construct(array $body, array $headers) { $this->body = $body; $this->headers = $headers; diff --git a/src/PactBuilder/JsonPatternBuilder.php b/src/PactBuilder/JsonPatternBuilder.php index 8392c78..c91a2ae 100644 --- a/src/PactBuilder/JsonPatternBuilder.php +++ b/src/PactBuilder/JsonPatternBuilder.php @@ -31,12 +31,10 @@ public function build(): Body $matchers = new MatcherCollector(); $content = self::extractRecursiveMatchingRules($this->content, '$', $matchers); - return Body::fromArray( - [ - 'content' => \json_encode($content, \JSON_THROW_ON_ERROR), - 'matching_rules' => $matchers->generateMatchingRules(), - ] - ); + return Body::fromArray([ + 'content' => $content, + 'matching_rules' => $matchers->generateMatchingRules(), + ]); } /** diff --git a/src/PactBuilder/MessageBuilder.php b/src/PactBuilder/MessageBuilder.php index 80358a9..6352d03 100644 --- a/src/PactBuilder/MessageBuilder.php +++ b/src/PactBuilder/MessageBuilder.php @@ -51,7 +51,7 @@ public function withJsonBody(callable $callable): self public function build(): Message { $body = $this->bodyBuilder === null - ? ['content' => '', 'matching_rules' => []] + ? ['content' => [], 'matching_rules' => []] : $this->bodyBuilder->build()->toArray(); return Message::fromArray([ diff --git a/tests/Definition/BodyTest.php b/tests/Definition/BodyTest.php index a5cac3b..68845db 100644 --- a/tests/Definition/BodyTest.php +++ b/tests/Definition/BodyTest.php @@ -17,19 +17,21 @@ final class BodyTest extends TestCase public function testItWillCreateFromPerfectPayload(): void { $body = Body::fromArray([ - 'content' => '{"some_json_value": true}', + 'content' => [ + 'some_json_value' => true, + ], 'matching_rules' => [ '$.some_json_value' => PayloadExample::matchingRule(), ], ]); - Assert::assertSame('{"some_json_value": true}', $body->content()); + Assert::assertSame(['some_json_value' => true], $body->content()); Assert::assertNotEmpty($body->matchingRules()->toArray()); $payload = $body->toArray(); Assert::assertArrayHasKey('content', $payload); - Assert::assertSame('{"some_json_value": true}', $payload['content']); + Assert::assertSame(['some_json_value' => true], $payload['content']); Assert::assertArrayHasKey('matching_rules', $payload); Assert::assertIsArray($payload['matching_rules']); @@ -52,13 +54,15 @@ public function testItWillThrowWithInvalidPayload(\Exception $expectedException, public function invalidPayloadProvider(): iterable { $perfectValues = [ - 'content' => '{"some_json_value": true}', + 'content' => [ + 'some_json_value' => true, + ], 'matching_rules' => [ '$.some_json_value' => PayloadExample::matchingRule(), ], ]; - yield from ValueObjectPayloadAssertion::string($perfectValues, 'content'); + yield from ValueObjectPayloadAssertion::array($perfectValues, 'content'); yield from ValueObjectPayloadAssertion::array($perfectValues, 'matching_rules'); } } diff --git a/tests/Definition/ConsumerTest.php b/tests/Definition/ConsumerTest.php index a451b53..9fd6647 100644 --- a/tests/Definition/ConsumerTest.php +++ b/tests/Definition/ConsumerTest.php @@ -24,6 +24,7 @@ public function testItWillCreateFromPerfectPayload(): void Assert::assertArrayHasKey('name', $payload); Assert::assertSame('test', $payload['name']); + Assert::assertSame('test', $consumer->name()); } /** diff --git a/tests/Definition/MessageTest.php b/tests/Definition/MessageTest.php index f390ea7..a2b9a80 100644 --- a/tests/Definition/MessageTest.php +++ b/tests/Definition/MessageTest.php @@ -20,14 +20,16 @@ public function testItWillCreateFromPerfectPayload(): void 'description' => 'test', 'provider_states' => PayloadExample::providerStates(), 'body' => [ - 'content' => '{"some": "value"}', + 'content' => [ + 'some' => 'value' + ], 'matching_rules' => [], ], 'metadata' => ['some' => 'value'], ]); Assert::assertSame('test', $message->description()->value()); - Assert::assertSame('{"some": "value"}', $message->body()->content()); + Assert::assertSame(['some' => 'value'], $message->body()->content()); Assert::assertSame(['some' => 'value'], $message->metadata()); $payload = $message->toArray(); @@ -56,7 +58,9 @@ public function invalidPayloadProvider(): iterable 'description' => PayloadExample::description(), 'provider_states' => PayloadExample::providerStates(), 'body' => [ - 'content' => '{"some": "value"}', + 'content' => [ + 'some' => 'value' + ], 'matching_rules' => [], ], 'metadata' => ['some' => 'value'], diff --git a/tests/Definition/PayloadExample.php b/tests/Definition/PayloadExample.php index 19010c4..9dc3f0d 100644 --- a/tests/Definition/PayloadExample.php +++ b/tests/Definition/PayloadExample.php @@ -75,7 +75,7 @@ public static function headers(): array public static function body(): array { return [ - 'content' => '{"some_json_value": true}', + 'content' => ['some_json_value' => true], 'matching_rules' => [ '$.some_json_value' => [ 'matchers' => [ @@ -163,7 +163,9 @@ public static function message(): array 'description' => self::description(), 'provider_states' => self::providerStates(), 'body' => [ - 'content' => '{"some": "value"}', + 'content' => [ + 'some' => 'value' + ], 'matching_rules' => [], ], 'metadata' => ['some' => 'value'], diff --git a/tests/Definition/ProviderTest.php b/tests/Definition/ProviderTest.php index 5482214..beb00ce 100644 --- a/tests/Definition/ProviderTest.php +++ b/tests/Definition/ProviderTest.php @@ -24,6 +24,7 @@ public function testItWillCreateFromPerfectPayload(): void Assert::assertArrayHasKey('name', $payload); Assert::assertSame('test', $payload['name']); + Assert::assertSame('test', $provider->name()); } /** diff --git a/tests/Generator/PactFileGeneratorTest.php b/tests/Generator/PactFileGeneratorTest.php index 4fa1e1f..fecca3f 100644 --- a/tests/Generator/PactFileGeneratorTest.php +++ b/tests/Generator/PactFileGeneratorTest.php @@ -55,7 +55,9 @@ public function testItGeneratesMessagePactFile(): void 'description' => 'test alpha', 'provider_states' => [], 'body' => [ - 'content' => '{"some": "value"}', + 'content' => [ + 'some' => 'value', + ], 'matching_rules' => [ '$.some' => [ 'matchers' => [ @@ -71,7 +73,11 @@ public function testItGeneratesMessagePactFile(): void 'description' => 'test beta', 'provider_states' => [], 'body' => [ - 'content' => '{"some": [{"deep": "value"}]}', + 'content' => [ + 'some' => [ + 'deep' => 'value', + ], + ], 'matching_rules' => [ '$.some[*]' => [ 'matchers' => [ @@ -104,7 +110,9 @@ public function testItGeneratesMessagePactFile(): void [ 'description' => 'test alpha', 'providerStates' => [], - 'contents' => '{"some": "value"}', + 'contents' => [ + 'some' => 'value', + ], 'metaData' => [], 'matchingRules' => [ 'body' => [ @@ -121,7 +129,11 @@ public function testItGeneratesMessagePactFile(): void [ 'description' => 'test beta', 'providerStates' => [], - 'contents' => '{"some": [{"deep": "value"}]}', + 'contents' => [ + 'some' => [ + 'deep' => 'value', + ], + ], 'metaData' => [], 'matchingRules' => [ 'body' => [ diff --git a/tests/Message/MessageTest.php b/tests/Message/MessageTest.php index 59f3b6f..bca4352 100644 --- a/tests/Message/MessageTest.php +++ b/tests/Message/MessageTest.php @@ -19,7 +19,9 @@ public function testItCreatesFromDefinition(): void { $messageDefinition = MessageDefinition::fromArray(\array_replace(PayloadExample::message(), [ 'body' => [ - 'content' => '{"some": "value"}', + 'content' => [ + 'some' => 'value', + ], 'matching_rules' => [], ], 'metadata' => ['metaAlpha' => 'data'], @@ -27,7 +29,7 @@ public function testItCreatesFromDefinition(): void $message = Message::fromMessageDefinition($messageDefinition); - Assert::assertSame('{"some": "value"}', $message->body()); + Assert::assertSame(['some' => 'value'], $message->body()); Assert::assertSame(['metaAlpha' => 'data'], $message->headers()); } } diff --git a/tests/PactBuilder/JsonPatternBuilderTest.php b/tests/PactBuilder/JsonPatternBuilderTest.php index abe45dc..c13cf59 100644 --- a/tests/PactBuilder/JsonPatternBuilderTest.php +++ b/tests/PactBuilder/JsonPatternBuilderTest.php @@ -23,10 +23,9 @@ public function testItBuildsMessage(): void $body = $builder->build(); - Assert::assertSame( - '{"some":"value"}', - $body->content() - ); + Assert::assertSame([ + 'some' => 'value', + ], $body->content()); Assert::assertSame([], $body->matchingRules()->toArray()); } @@ -49,11 +48,11 @@ public function testItGeneratesWithSimplePattern(): void $body = $builder->build(); - Assert::assertSame(\json_encode([ + Assert::assertSame([ 'some' => [ 'deep' => 'value', ], - ], \JSON_THROW_ON_ERROR), $body->content()); + ], $body->content()); Assert::assertSame(MatchingRules::fromArray([ ])->toArray(), $body->matchingRules()->toArray()); @@ -68,9 +67,9 @@ public function testItGeneratesWithTypePattern(): void $body = $builder->build(); - Assert::assertSame(\json_encode([ + Assert::assertSame([ 'some' => 'value', - ], \JSON_THROW_ON_ERROR), $body->content()); + ], $body->content()); Assert::assertSame(MatchingRules::fromArray([ '$.some' => [ @@ -90,9 +89,7 @@ public function testItGeneratesWithExpressionPattern(): void $body = $builder->build(); - Assert::assertSame(\json_encode([ - 'some' => 'value', - ], \JSON_THROW_ON_ERROR), $body->content()); + Assert::assertSame(['some' => 'value'], $body->content()); Assert::assertSame(MatchingRules::fromArray([ '$.some' => [ @@ -114,9 +111,7 @@ public function testItGeneratesWithArrayPattern(): void $body = $builder->build(); - Assert::assertSame(\json_encode([ - 'each_like' => [1], - ], \JSON_THROW_ON_ERROR), $body->content()); + Assert::assertSame(['each_like' => [1]], $body->content()); Assert::assertSame(MatchingRules::fromArray([ '$.each_like' => [ @@ -143,11 +138,11 @@ public function testItGeneratesWithObjectPattern(): void $body = $builder->build(); - Assert::assertSame(\json_encode([ + Assert::assertSame([ 'each_like' => [ ['value' => 1], ], - ], \JSON_THROW_ON_ERROR), $body->content()); + ], $body->content()); Assert::assertSame(MatchingRules::fromArray([ '$.each_like' => [ @@ -185,7 +180,7 @@ public function testItGeneratesWithPaths(): void $body = $builder->build(); - Assert::assertSame(\json_encode([ + Assert::assertSame([ 'array' => [ 1, 2 @@ -200,7 +195,7 @@ public function testItGeneratesWithPaths(): void ], '"' => 1, "'" => 1, - ], \JSON_THROW_ON_ERROR), $body->content()); + ], $body->content()); Assert::assertSame(MatchingRules::fromArray([ "$.array[0]" => [ diff --git a/tests/PactBuilder/MessageBuilderTest.php b/tests/PactBuilder/MessageBuilderTest.php index e87c667..1d59bde 100644 --- a/tests/PactBuilder/MessageBuilderTest.php +++ b/tests/PactBuilder/MessageBuilderTest.php @@ -38,7 +38,7 @@ public function testItBuildsMessageWithEmptyBody(): void ->expectsToReceive('test description') )->build(); - Assert::assertSame('', $message->body()->content()); + Assert::assertSame([], $message->body()->content()); } public function testItIsImmutable(): void