Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compatibility-suite): Clean up mock server #688

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/compatibility-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -70,3 +76,5 @@ jobs:

- name: Run Behat
run: vendor/bin/behat compatibility-suite/pact-compatibility-suite/features/V4 --colors
env:
PACT_LOGLEVEL: debug
6 changes: 6 additions & 0 deletions compatibility-suite/tests/Service/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,10 @@ public function getPort(): int
{
return $this->config->getPort();
}

public function __destruct()
{
// Clean up mock server
$this->getVerifyResult();
}
}
3 changes: 3 additions & 0 deletions src/PhpPact/Consumer/Driver/Pact/PactDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/PhpPact/Consumer/Driver/Pact/PactDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testCleanUp(): void

public function testCleanUpWithoutPact(): void
{
$this->expectException(MissingPactException::class);
$this->expectNotToPerformAssertions();
$this->driver->cleanUp();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,7 +50,7 @@ public function testCleanUpPlugin(): void

public function testCleanUpPluginWithoutPact(): void
{
$this->expectException(MissingPactException::class);
$this->expectNotToPerformAssertions();
$this->driver->cleanUp();
}

Expand Down