diff --git a/composer.json b/composer.json
index 1e00fb475..ee15a3309 100644
--- a/composer.json
+++ b/composer.json
@@ -86,7 +86,8 @@
"composer run-example:xml",
"composer run-example:graphql",
"composer run-example:form-urlencoded",
- "composer run-example:server-sent-events"
+ "composer run-example:server-sent-events",
+ "composer run-example:repeated-headers"
],
"run-examples:windows": [
"composer run-example:binary:windows",
@@ -102,7 +103,8 @@
"composer run-example:xml:windows",
"composer run-example:graphql:windows",
"composer run-example:form-urlencoded:windows",
- "composer run-example:server-sent-events:windows"
+ "composer run-example:server-sent-events:windows",
+ "composer run-example:repeated-headers:windows"
],
"run-example:binary:windows": [
"powershell -Command \"if (Test-Path 'example/binary/pacts/binaryConsumer-binaryProvider.json') { Remove-Item 'example/binary/pacts/binaryConsumer-binaryProvider.json' }\"",
@@ -239,17 +241,25 @@
"rm -f example/server-sent-events/pacts/sseConsumer-sseProvider.json",
"cd example/server-sent-events/consumer && phpunit",
"cd example/server-sent-events/provider && phpunit"
+ ],
+ "run-example:repeated-headers:windows": [
+ "powershell -Command \"if (Test-Path 'example/repeated-headers/pacts/repeatedHeadersConsumer-repeatedHeadersProvider.json') { Remove-Item 'example/repeated-headers/pacts/repeatedHeadersConsumer-repeatedHeadersProvider.json' }\"",
+ "cd example/repeated-headers/consumer && phpunit --process-isolation"
+ ],
+ "run-example:repeated-headers": [
+ "rm -f example/repeated-headers/pacts/repeatedHeadersConsumer-repeatedHeadersProvider.json",
+ "cd example/repeated-headers/consumer && phpunit"
]
},
"extra": {
"downloads": {
"pact-ffi-headers": {
- "version": "0.5.10",
- "url": "https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v{$version}/pact.h",
+ "version": "0.5.13-rc.1",
+ "url": "https://github.com/YOU54F/pact-reference/releases/download/libpact_ffi-v{$version}/pact.h",
"path": "bin/pact-ffi-headers/pact.h"
},
"pact-ffi-lib": {
- "version": "0.5.10",
+ "version": "0.5.13-rc.1",
"variables": {
"{$prefix}": "PHP_OS_FAMILY === 'Windows' ? 'pact_ffi' : 'libpact_ffi'",
"{$os}": "PHP_OS === 'Darwin' ? 'macos' : strtolower(PHP_OS_FAMILY)",
@@ -257,7 +267,7 @@
"{$musl}": "PHP_OS === 'Linux' && musl() === true ? '-musl' : ''",
"{$extension}": "PHP_OS_FAMILY === 'Windows' ? 'dll' : (PHP_OS === 'Darwin' ? 'dylib' : 'so')"
},
- "url": "https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v{$version}/{$prefix}-{$os}-{$architecture}{$musl}.{$extension}.gz",
+ "url": "https://github.com/YOU54F/pact-reference/releases/download/libpact_ffi-v{$version}/{$prefix}-{$os}-{$architecture}{$musl}.{$extension}.gz",
"path": "bin/pact-ffi-lib/pact.{$extension}"
},
"pact-stub-server": {
diff --git a/example/repeated-headers/consumer/autoload.php b/example/repeated-headers/consumer/autoload.php
new file mode 100644
index 000000000..04da21e90
--- /dev/null
+++ b/example/repeated-headers/consumer/autoload.php
@@ -0,0 +1,6 @@
+addPsr4('RepeatedHeadersConsumer\\', __DIR__ . '/src');
+$loader->addPsr4('RepeatedHeadersConsumer\\Tests\\', __DIR__ . '/tests');
diff --git a/example/repeated-headers/consumer/phpunit.xml b/example/repeated-headers/consumer/phpunit.xml
new file mode 100644
index 000000000..3dae1948a
--- /dev/null
+++ b/example/repeated-headers/consumer/phpunit.xml
@@ -0,0 +1,8 @@
+
+
+
+
+ ./tests
+
+
+
diff --git a/example/repeated-headers/consumer/src/Service/HttpClientService.php b/example/repeated-headers/consumer/src/Service/HttpClientService.php
new file mode 100644
index 000000000..bfff042b7
--- /dev/null
+++ b/example/repeated-headers/consumer/src/Service/HttpClientService.php
@@ -0,0 +1,56 @@
+ $fieldLines list of [name, value] pairs, one per field line
+ *
+ * @return int the response status code
+ */
+ public function getHeaders(array $fieldLines): int
+ {
+ $host = $this->baseUri->getHost();
+ $port = (int) $this->baseUri->getPort();
+ $socket = stream_socket_client("tcp://{$host}:{$port}", $errorCode, $errorMessage, 5);
+ if ($socket === false) {
+ throw new RuntimeException(sprintf('Can not connect to %s:%d: %s (%d)', $host, $port, $errorMessage, $errorCode));
+ }
+
+ try {
+ stream_set_timeout($socket, 5);
+ $request = "GET /headers HTTP/1.1\r\n";
+ $request .= "Host: {$host}:{$port}\r\n";
+ foreach ($fieldLines as [$name, $value]) {
+ $request .= "{$name}: {$value}\r\n";
+ }
+ $request .= "Connection: close\r\n\r\n";
+ fwrite($socket, $request);
+
+ $statusLine = fgets($socket);
+ if ($statusLine === false || !preg_match('/^HTTP\/1\.[01] (\d{3})/', $statusLine, $matches)) {
+ throw new RuntimeException(sprintf('Invalid status line: %s', var_export($statusLine, true)));
+ }
+ // Drain the rest of the response so the mock server finishes handling the request.
+ stream_get_contents($socket);
+
+ return (int) $matches[1];
+ } finally {
+ fclose($socket);
+ }
+ }
+}
diff --git a/example/repeated-headers/consumer/tests/Service/RepeatedHeadersTest.php b/example/repeated-headers/consumer/tests/Service/RepeatedHeadersTest.php
new file mode 100644
index 000000000..0fe1ee71b
--- /dev/null
+++ b/example/repeated-headers/consumer/tests/Service/RepeatedHeadersTest.php
@@ -0,0 +1,188 @@
+attach(new Buffer(LogLevel::WARN));
+ $logger->apply();
+ }
+
+ /**
+ * @return iterable, array, bool}>
+ */
+ public static function repeatedHeaderProvider(): iterable
+ {
+ yield 'H1 two field lines match two values' => [
+ 'X-Request',
+ ['a', 'b'],
+ [['X-Request', 'a'], ['X-Request', 'b']],
+ true,
+ ];
+ yield 'H2 one comma-joined field line matches two values' => [
+ 'X-Request',
+ ['a', 'b'],
+ [['X-Request', 'a, b']],
+ true,
+ ];
+ yield 'H3 values containing commas, one per field line' => [
+ 'X-Sunset',
+ ['Sat, 01 Jan 2028 00:00:00 GMT', 'Sun, 02 Jan 2028 00:00:00 GMT'],
+ [['X-Sunset', 'Sat, 01 Jan 2028 00:00:00 GMT'], ['X-Sunset', 'Sun, 02 Jan 2028 00:00:00 GMT']],
+ true,
+ ];
+ yield 'H4 Content-Type is not a list, so a comma-joined line does not match' => [
+ 'Content-Type',
+ ['text/plain', 'text/html'],
+ [['Content-Type', 'text/plain, text/html']],
+ false,
+ ];
+ yield 'H5 Cache-Control comma-joined field line matches two values' => [
+ 'Cache-Control',
+ ['no-cache', 'no-store'],
+ [['Cache-Control', 'no-cache, no-store']],
+ true,
+ ];
+ yield 'H8a Link values containing commas, one per field line' => [
+ 'Link',
+ ['; rel="a"', '; rel="b"'],
+ [['Link', '; rel="a"'], ['Link', '; rel="b"']],
+ true,
+ ];
+ yield 'H8b Link values containing commas, one comma-joined field line' => [
+ 'Link',
+ ['; rel="a"', '; rel="b"'],
+ [['Link', '; rel="a", ; rel="b"']],
+ true,
+ ];
+ }
+
+ /**
+ * @param array $expectedValues
+ * @param array $fieldLines
+ */
+ #[DataProvider('repeatedHeaderProvider')]
+ public function testRepeatedHeader(string $header, array $expectedValues, array $fieldLines, bool $shouldMatch): void
+ {
+ [$status, $matched, $mismatches] = $this->runInteraction((string) $this->dataName(), $header, $expectedValues, $fieldLines);
+
+ if ($shouldMatch) {
+ $this->assertSame(200, $status);
+ $this->assertTrue($matched, $mismatches);
+ } else {
+ $this->assertNotSame(200, $status);
+ $this->assertFalse($matched);
+ $this->assertNotEmpty(json_decode($mismatches, true), $mismatches);
+ }
+ }
+
+ public function testH6aRegexMatcherPerIndexMatchesWithoutWarning(): void
+ {
+ $regex = '^first-\d+$';
+ [$status, $matched, $mismatches, $logs] = $this->runInteraction(
+ 'H6a one regex matcher per index',
+ 'X-Request',
+ [self::$matcher->regex('first-1', $regex), self::$matcher->regex('first-2', $regex)],
+ [['X-Request', 'first-42'], ['X-Request', 'first-99']],
+ );
+
+ $this->assertSame(200, $status);
+ $this->assertTrue($matched, $mismatches);
+ $this->assertStringNotContainsString(self::DEPRECATION_WARNING, $logs);
+ }
+
+ /**
+ * Whitespace inside a quoted-string is literal (RFC 9110 §5.6.4), so the
+ * expected `"x , y"` does not match the sent `"x, y"`, and there is no
+ * per-line fallback that would log the deprecation warning.
+ */
+ public function testH6bQuotedValueWhitespaceIsLiteralAndDoesNotMatch(): void
+ {
+ [$status, $matched, $mismatches, $logs] = $this->runInteraction(
+ 'H6b quoted value containing a comma, one per field line',
+ 'X-Request',
+ ['"x , y"', 'z'],
+ [['X-Request', '"x, y"'], ['X-Request', 'z']],
+ );
+
+ $this->assertNotSame(200, $status);
+ $this->assertFalse($matched);
+ $this->assertNotEmpty(json_decode($mismatches, true), $mismatches);
+ $this->assertStringNotContainsString(self::DEPRECATION_WARNING, $logs);
+ }
+
+ /**
+ * @param array $expectedValues
+ * @param array $fieldLines
+ *
+ * @return array{int, bool, string, string} status, matched, mismatches, mock server logs
+ */
+ private function runInteraction(string $description, string $header, array $expectedValues, array $fieldLines): array
+ {
+ $request = new ConsumerRequest();
+ $request
+ ->setMethod('GET')
+ ->setPath('/headers')
+ ->addHeader($header, $expectedValues);
+
+ $response = new ProviderResponse();
+ $response->setStatus(200);
+
+ $config = new MockServerConfig();
+ $config
+ ->setConsumer('repeatedHeadersConsumer')
+ ->setProvider('repeatedHeadersProvider')
+ ->setPactSpecificationVersion('3.0.0')
+ ->setPactDir(__DIR__ . '/../../../pacts');
+
+ $builder = new InteractionBuilder($config);
+ $builder
+ ->uponReceiving($description)
+ ->with($request)
+ ->willRespondWith($response);
+
+ $status = (new HttpClientService($config->getBaseUri()))->getHeaders($fieldLines);
+
+ // The mock server is cleaned up by `verify()`. Its mismatches and logs (it logs
+ // to its own buffer, not the one returned by `Logger::fetchBuffer()`) are kept
+ // in the verify result.
+ $matched = $builder->verify();
+ $result = $builder->getVerifyResult();
+ $this->assertNotNull($result);
+
+ return [$status, $matched, $result->mismatches, $result->logs];
+ }
+}
diff --git a/example/repeated-headers/pacts/repeatedHeadersConsumer-repeatedHeadersProvider.json b/example/repeated-headers/pacts/repeatedHeadersConsumer-repeatedHeadersProvider.json
new file mode 100644
index 000000000..601ed641a
--- /dev/null
+++ b/example/repeated-headers/pacts/repeatedHeadersConsumer-repeatedHeadersProvider.json
@@ -0,0 +1,124 @@
+{
+ "consumer": {
+ "name": "repeatedHeadersConsumer"
+ },
+ "interactions": [
+ {
+ "description": "H1 two field lines match two values",
+ "request": {
+ "headers": {
+ "X-Request": "a, b"
+ },
+ "method": "GET",
+ "path": "/headers"
+ },
+ "response": {
+ "status": 200
+ }
+ },
+ {
+ "description": "H2 one comma-joined field line matches two values",
+ "request": {
+ "headers": {
+ "X-Request": "a, b"
+ },
+ "method": "GET",
+ "path": "/headers"
+ },
+ "response": {
+ "status": 200
+ }
+ },
+ {
+ "description": "H3 values containing commas, one per field line",
+ "request": {
+ "headers": {
+ "X-Sunset": "Sat, 01 Jan 2028 00:00:00 GMT, Sun, 02 Jan 2028 00:00:00 GMT"
+ },
+ "method": "GET",
+ "path": "/headers"
+ },
+ "response": {
+ "status": 200
+ }
+ },
+ {
+ "description": "H5 Cache-Control comma-joined field line matches two values",
+ "request": {
+ "headers": {
+ "Cache-Control": "no-cache, no-store"
+ },
+ "method": "GET",
+ "path": "/headers"
+ },
+ "response": {
+ "status": 200
+ }
+ },
+ {
+ "description": "H6a one regex matcher per index",
+ "request": {
+ "headers": {
+ "X-Request": "first-1, first-2"
+ },
+ "matchingRules": {
+ "header": {
+ "X-Request": {
+ "combine": "AND",
+ "matchers": [
+ {
+ "match": "regex",
+ "regex": "^first-\\d+$"
+ }
+ ]
+ }
+ }
+ },
+ "method": "GET",
+ "path": "/headers"
+ },
+ "response": {
+ "status": 200
+ }
+ },
+ {
+ "description": "H8a Link values containing commas, one per field line",
+ "request": {
+ "headers": {
+ "Link": "; rel=\"a\", ; rel=\"b\""
+ },
+ "method": "GET",
+ "path": "/headers"
+ },
+ "response": {
+ "status": 200
+ }
+ },
+ {
+ "description": "H8b Link values containing commas, one comma-joined field line",
+ "request": {
+ "headers": {
+ "Link": "; rel=\"a\", ; rel=\"b\""
+ },
+ "method": "GET",
+ "path": "/headers"
+ },
+ "response": {
+ "status": 200
+ }
+ }
+ ],
+ "metadata": {
+ "pactRust": {
+ "ffi": "0.5.13-rc.1",
+ "mockserver": "2.2.6",
+ "models": "1.3.17"
+ },
+ "pactSpecification": {
+ "version": "3.0.0"
+ }
+ },
+ "provider": {
+ "name": "repeatedHeadersProvider"
+ }
+}
\ No newline at end of file
diff --git a/helper/FFI/ClientTrait.php b/helper/FFI/ClientTrait.php
index 6291dedf4..a51d221f6 100644
--- a/helper/FFI/ClientTrait.php
+++ b/helper/FFI/ClientTrait.php
@@ -396,6 +396,15 @@ protected function expectsMockServerMismatches(int $port, string $result, bool $
}
}
+ protected function expectsMockServerLogs(int $port, string $result): void
+ {
+ $this->client
+ ->expects($this->once())
+ ->method('mockServerLogs')
+ ->with($port)
+ ->willReturn($result);
+ }
+
protected function expectsWritePactFile(int $port, string $directory, bool $overwrite, int $result, bool $matched): void
{
if ($matched) {
diff --git a/phpstan.neon b/phpstan.neon
index 575705a16..ad2241ed7 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -34,6 +34,7 @@ parameters:
- example/protobuf-async-message/provider/autoload.php
- example/protobuf-sync-message/consumer/autoload.php
- example/protobuf-sync-message/provider/autoload.php
+ - example/repeated-headers/consumer/autoload.php
- example/server-sent-events/consumer/autoload.php
- example/server-sent-events/provider/autoload.php
- example/stub-server/consumer/autoload.php
diff --git a/src/PhpPact/Consumer/InteractionBuilder.php b/src/PhpPact/Consumer/InteractionBuilder.php
index 1ce0b27f7..6eeca2157 100644
--- a/src/PhpPact/Consumer/InteractionBuilder.php
+++ b/src/PhpPact/Consumer/InteractionBuilder.php
@@ -9,6 +9,7 @@
use PhpPact\Consumer\Model\Interaction;
use PhpPact\Consumer\Model\ProviderResponse;
use PhpPact\Standalone\MockService\MockServerConfigInterface;
+use PhpPact\Standalone\MockService\Model\VerifyResult;
/**
* Build an interaction and send it to the Ruby Standalone Mock Service
@@ -17,6 +18,7 @@ class InteractionBuilder implements BuilderInterface
{
private readonly InteractionDriverInterface $driver;
private Interaction $interaction;
+ private ?VerifyResult $verifyResult = null;
public function __construct(MockServerConfigInterface $config, ?InteractionDriverFactoryInterface $driverFactory = null)
{
@@ -79,7 +81,18 @@ public function willRespondWith(ProviderResponse $response, bool $startMockServe
*/
public function verify(): bool
{
- return $this->driver->verifyInteractions()->matched;
+ $this->verifyResult = $this->driver->verifyInteractions();
+
+ return $this->verifyResult->matched;
+ }
+
+ /**
+ * Result of the last call to {@see self::verify()}: mismatches (JSON) and mock server logs.
+ * Returns null if {@see self::verify()} has not been called yet.
+ */
+ public function getVerifyResult(): ?VerifyResult
+ {
+ return $this->verifyResult;
}
/**
diff --git a/src/PhpPact/Consumer/Service/MockServer.php b/src/PhpPact/Consumer/Service/MockServer.php
index c35d0ae13..6f61db3c4 100644
--- a/src/PhpPact/Consumer/Service/MockServer.php
+++ b/src/PhpPact/Consumer/Service/MockServer.php
@@ -42,6 +42,7 @@ public function verify(): VerifyResult
usleep(10000); // Wait for last request reach mock server (TODO find better way)
try {
$matched = $this->isMatched();
+ $logs = $this->getLogs();
if ($matched) {
$this->writePact();
@@ -49,7 +50,7 @@ public function verify(): VerifyResult
$mismatches = $this->getMismatches();
}
- return new VerifyResult($matched, $mismatches ?? '');
+ return new VerifyResult($matched, $mismatches ?? '', $logs);
} finally {
$this->cleanUp();
}
@@ -95,4 +96,9 @@ private function getMismatches(): string
{
return $this->client->mockServerMismatches($this->config->getPort());
}
+
+ private function getLogs(): string
+ {
+ return $this->client->mockServerLogs($this->config->getPort());
+ }
}
diff --git a/src/PhpPact/FFI/Client.php b/src/PhpPact/FFI/Client.php
index a35ebacda..f29d127a7 100644
--- a/src/PhpPact/FFI/Client.php
+++ b/src/PhpPact/FFI/Client.php
@@ -291,6 +291,19 @@ public function mockServerMismatches(int $port): string
return FFI::string($result);
}
+ public function mockServerLogs(int $port): string
+ {
+ $method = 'pactffi_mock_server_logs';
+ $result = $this->call($method, $port);
+ if ($result === null) {
+ return '';
+ }
+ if (!is_string($result)) {
+ throw new InvalidResultException(sprintf('Invalid result of "%s". Expected "string", but got "%s"', $method, get_debug_type($result)));
+ }
+ return $result;
+ }
+
public function writePactFile(int $port, string $directory, bool $overwrite): int
{
$method = 'pactffi_write_pact_file';
diff --git a/src/PhpPact/FFI/ClientInterface.php b/src/PhpPact/FFI/ClientInterface.php
index 1b8f01c39..46f950804 100644
--- a/src/PhpPact/FFI/ClientInterface.php
+++ b/src/PhpPact/FFI/ClientInterface.php
@@ -65,6 +65,8 @@ public function mockServerMatched(int $port): bool;
public function mockServerMismatches(int $port): string;
+ public function mockServerLogs(int $port): string;
+
public function writePactFile(int $port, string $directory, bool $overwrite): int;
public function createMockServerForTransport(int $pact, string $host, int $port, string $transport, ?string $transportConfig): int;
diff --git a/src/PhpPact/Standalone/MockService/Model/VerifyResult.php b/src/PhpPact/Standalone/MockService/Model/VerifyResult.php
index 7cffd732d..c7a07648e 100644
--- a/src/PhpPact/Standalone/MockService/Model/VerifyResult.php
+++ b/src/PhpPact/Standalone/MockService/Model/VerifyResult.php
@@ -4,7 +4,15 @@
class VerifyResult
{
- public function __construct(public readonly bool $matched, public readonly string $mismatches)
- {
+ /**
+ * @param bool $matched whether all requests received by the mock server matched the interactions
+ * @param string $mismatches JSON encoded mismatches, empty if matched
+ * @param string $logs logs of the mock server, captured before it was cleaned up. Only filled if a buffer log sink is set up
+ */
+ public function __construct(
+ public readonly bool $matched,
+ public readonly string $mismatches,
+ public readonly string $logs = '',
+ ) {
}
}
diff --git a/src/PhpPact/SyncMessage/SyncMessageBuilder.php b/src/PhpPact/SyncMessage/SyncMessageBuilder.php
index d5ed27ec6..c57da7310 100644
--- a/src/PhpPact/SyncMessage/SyncMessageBuilder.php
+++ b/src/PhpPact/SyncMessage/SyncMessageBuilder.php
@@ -8,12 +8,14 @@
use PhpPact\SyncMessage\Factory\SyncMessageDriverFactory;
use PhpPact\SyncMessage\Factory\SyncMessageDriverFactoryInterface;
use PhpPact\Standalone\MockService\MockServerConfigInterface;
+use PhpPact\Standalone\MockService\Model\VerifyResult;
use PhpPact\SyncMessage\Model\SyncMessage;
class SyncMessageBuilder implements BuilderInterface
{
protected SyncMessage $message;
private SyncMessageDriverInterface $driver;
+ private ?VerifyResult $verifyResult = null;
public function __construct(MockServerConfigInterface $config, ?SyncMessageDriverFactoryInterface $driverFactory = null)
{
@@ -148,6 +150,17 @@ public function registerMessage(): void
public function verify(): bool
{
- return $this->driver->verifyMessage()->matched;
+ $this->verifyResult = $this->driver->verifyMessage();
+
+ return $this->verifyResult->matched;
+ }
+
+ /**
+ * Result of the last call to {@see self::verify()}: mismatches (JSON) and mock server logs.
+ * Returns null if {@see self::verify()} has not been called yet.
+ */
+ public function getVerifyResult(): ?VerifyResult
+ {
+ return $this->verifyResult;
}
}
diff --git a/tests/PhpPact/Consumer/InteractionBuilderTest.php b/tests/PhpPact/Consumer/InteractionBuilderTest.php
index 59f6b8617..aff04f42b 100644
--- a/tests/PhpPact/Consumer/InteractionBuilderTest.php
+++ b/tests/PhpPact/Consumer/InteractionBuilderTest.php
@@ -93,11 +93,14 @@ public function testWillRespondWith(bool $startMockServer, bool $result): void
#[TestWith([true])]
public function testVerify(bool $matched): void
{
+ $result = new VerifyResult($matched, $matched ? '' : '[{"type":"request-mismatch"}]', 'mock server logs');
$this->driver
->expects($this->once())
->method('verifyInteractions')
- ->willReturn(new VerifyResult($matched, ''));
+ ->willReturn($result);
+ $this->assertNull($this->builder->getVerifyResult());
$this->assertSame($matched, $this->builder->verify());
+ $this->assertSame($result, $this->builder->getVerifyResult());
}
#[TestWith([null])]
diff --git a/tests/PhpPact/Consumer/Service/MockServerTest.php b/tests/PhpPact/Consumer/Service/MockServerTest.php
index 4b16c0af8..a24fe9b6a 100644
--- a/tests/PhpPact/Consumer/Service/MockServerTest.php
+++ b/tests/PhpPact/Consumer/Service/MockServerTest.php
@@ -67,14 +67,17 @@ public function testVerify(bool $matched): void
$this->config->setPactDir($this->pactDir);
$this->expectsMockServerMatched($this->port, $matched);
$this->expectsWritePactFile($this->port, $this->pactDir, false, 0, $matched);
- $this->expectsMockServerMismatches($this->port, '', $matched);
+ $mismatches = $matched ? '' : '[{"type":"request-mismatch"}]';
+ $this->expectsMockServerMismatches($this->port, $mismatches, $matched);
+ $this->expectsMockServerLogs($this->port, 'mock server logs');
$this->expectsCleanupMockServer($this->port, true);
$this->pactDriver
->expects($this->once())
->method('cleanUp');
$result = $this->mockServer->verify();
$this->assertSame($matched, $result->matched);
- $this->assertSame('', $result->mismatches);
+ $this->assertSame($mismatches, $result->mismatches);
+ $this->assertSame('mock server logs', $result->logs);
}
#[TestWith([0, WriteMode::OVERWRITE])]
diff --git a/tests/PhpPact/FFI/ClientTest.php b/tests/PhpPact/FFI/ClientTest.php
index 9d7c5850a..da54a4283 100644
--- a/tests/PhpPact/FFI/ClientTest.php
+++ b/tests/PhpPact/FFI/ClientTest.php
@@ -186,6 +186,12 @@ public function testMockServerMismatches(): void
$this->assertSame('', $result);
}
+ public function testMockServerLogs(): void
+ {
+ $result = $this->client->mockServerLogs(1234);
+ $this->assertSame('', $result);
+ }
+
public function testWritePactFile(): void
{
$result = $this->client->writePactFile(1234, 'test', true);
diff --git a/tests/PhpPact/SyncMessage/SyncMessageBuilderTest.php b/tests/PhpPact/SyncMessage/SyncMessageBuilderTest.php
index 5031585ca..70b92bcfb 100644
--- a/tests/PhpPact/SyncMessage/SyncMessageBuilderTest.php
+++ b/tests/PhpPact/SyncMessage/SyncMessageBuilderTest.php
@@ -136,11 +136,14 @@ public function testRegisterMessage(): void
#[TestWith([true])]
public function testVerify(bool $matched): void
{
+ $result = new VerifyResult($matched, $matched ? '' : '[{"type":"request-mismatch"}]', 'mock server logs');
$this->driver
->expects($this->once())
->method('verifyMessage')
- ->willReturn(new VerifyResult($matched, ''));
+ ->willReturn($result);
+ $this->assertNull($this->builder->getVerifyResult());
$this->assertSame($matched, $this->builder->verify());
+ $this->assertSame($result, $this->builder->getVerifyResult());
}
private function getMessage(): Message