Skip to content

Commit

Permalink
Merge pull request #688 from tienvx/fix-conflict-pact-file-name
Browse files Browse the repository at this point in the history
fix(compatibility-suite): Clean up mock server
  • Loading branch information
tienvx authored Oct 21, 2024
2 parents 11a6c4a + 4d98388 commit ef3957e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
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

0 comments on commit ef3957e

Please sign in to comment.