diff --git a/.github/workflows/compatibility-suite.yml b/.github/workflows/compatibility-suite.yml index 62a9abbe..9a5af875 100644 --- a/.github/workflows/compatibility-suite.yml +++ b/.github/workflows/compatibility-suite.yml @@ -22,6 +22,8 @@ jobs: - name: Run Behat run: vendor/bin/behat compatibility-suite/pact-compatibility-suite/features/V1 --colors + env: + PACT_LOGLEVEL: debug v2: runs-on: ubuntu-latest steps: @@ -38,6 +40,8 @@ jobs: - name: Run Behat run: vendor/bin/behat compatibility-suite/pact-compatibility-suite/features/V2 --colors + env: + PACT_LOGLEVEL: debug v3: runs-on: ubuntu-latest steps: @@ -54,6 +58,8 @@ jobs: - name: Run Behat run: vendor/bin/behat compatibility-suite/pact-compatibility-suite/features/V3 --name '/^((?!binary body \(negative|Message provider).)*$/' --colors + env: + PACT_LOGLEVEL: debug v4: runs-on: ubuntu-latest steps: @@ -70,3 +76,5 @@ jobs: - name: Run Behat run: vendor/bin/behat compatibility-suite/pact-compatibility-suite/features/V4 --colors + env: + PACT_LOGLEVEL: debug diff --git a/compatibility-suite/tests/Service/Server.php b/compatibility-suite/tests/Service/Server.php index c4580f8b..36f58740 100644 --- a/compatibility-suite/tests/Service/Server.php +++ b/compatibility-suite/tests/Service/Server.php @@ -77,4 +77,10 @@ public function getPort(): int { return $this->config->getPort(); } + + public function __destruct() + { + // Clean up mock server + $this->getVerifyResult(); + } } diff --git a/src/PhpPact/Consumer/Driver/Pact/PactDriver.php b/src/PhpPact/Consumer/Driver/Pact/PactDriver.php index e2de57df..b19c28ef 100644 --- a/src/PhpPact/Consumer/Driver/Pact/PactDriver.php +++ b/src/PhpPact/Consumer/Driver/Pact/PactDriver.php @@ -23,6 +23,9 @@ public function __construct( public function cleanUp(): void { + if (!$this->pact) { + return; + } $success = $this->client->freePactHandle($this->getPact()->handle) === 0; if (!$success) { trigger_error('Can not free pact handle. The handle is not valid or does not refer to a valid Pact. Could be that it was previously deleted.', E_USER_WARNING); diff --git a/tests/PhpPact/Consumer/Driver/Pact/PactDriverTest.php b/tests/PhpPact/Consumer/Driver/Pact/PactDriverTest.php index 9e3e81cd..b754c662 100644 --- a/tests/PhpPact/Consumer/Driver/Pact/PactDriverTest.php +++ b/tests/PhpPact/Consumer/Driver/Pact/PactDriverTest.php @@ -81,7 +81,7 @@ public function testCleanUp(): void public function testCleanUpWithoutPact(): void { - $this->expectException(MissingPactException::class); + $this->expectNotToPerformAssertions(); $this->driver->cleanUp(); } diff --git a/tests/PhpPact/Plugin/Driver/Pact/AbstractPluginPactDriverTestCase.php b/tests/PhpPact/Plugin/Driver/Pact/AbstractPluginPactDriverTestCase.php index 3d0b7d78..6a6a05cf 100644 --- a/tests/PhpPact/Plugin/Driver/Pact/AbstractPluginPactDriverTestCase.php +++ b/tests/PhpPact/Plugin/Driver/Pact/AbstractPluginPactDriverTestCase.php @@ -2,7 +2,6 @@ namespace PhpPactTest\Plugin\Driver\Pact; -use PhpPact\Consumer\Driver\Exception\MissingPactException; use PhpPact\Plugin\Driver\Pact\AbstractPluginPactDriver; use PhpPact\Plugin\Exception\PluginNotSupportedBySpecificationException; use PhpPactTest\Consumer\Driver\Pact\PactDriverTest; @@ -51,7 +50,7 @@ public function testCleanUpPlugin(): void public function testCleanUpPluginWithoutPact(): void { - $this->expectException(MissingPactException::class); + $this->expectNotToPerformAssertions(); $this->driver->cleanUp(); }