-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: reorganize examples (create separate directory for each example)
- Loading branch information
Showing
30 changed files
with
251 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="../../../vendor/autoload.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="PhpPact Example Tests"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="PACT_LOGLEVEL" value="DEBUG"/> | ||
</php> | ||
</phpunit> |
2 changes: 1 addition & 1 deletion
2
...rc/Consumer/Service/HttpClientService.php → ...onsumer/src/Service/HttpClientService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="../../../vendor/autoload.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="PhpPact Example Tests"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="PACT_LOGLEVEL" value="DEBUG"/> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace JsonProvider; | ||
|
||
class ExampleProvider | ||
{ | ||
private array $currentState = []; | ||
|
||
public function sayHello(string $name): string | ||
{ | ||
return "Hello, {$name}"; | ||
} | ||
|
||
public function sayGoodbye(string $name): string | ||
{ | ||
return "Goodbye, {$name}"; | ||
} | ||
|
||
public function changeSate(string $action, string $state, array $params): void | ||
{ | ||
$this->currentState = [ | ||
'action' => $action, | ||
'state' => $state, | ||
'params' => $params, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace JsonProvider\Tests; | ||
|
||
use GuzzleHttp\Psr7\Uri; | ||
use PhpPact\Standalone\ProviderVerifier\Model\VerifierConfig; | ||
use PhpPact\Standalone\ProviderVerifier\Verifier; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Process\Process; | ||
|
||
class PactVerifyTest extends TestCase | ||
{ | ||
private Process $process; | ||
|
||
/** | ||
* Run the PHP build-in web server. | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$publicPath = __DIR__ . '/../public/'; | ||
|
||
$this->process = new Process(['php', '-S', '127.0.0.1:7202', '-t', $publicPath]); | ||
|
||
$this->process->start(); | ||
$this->process->waitUntil(function (): bool { | ||
$fp = @fsockopen('127.0.0.1', 7202); | ||
$isOpen = is_resource($fp); | ||
if ($isOpen) { | ||
fclose($fp); | ||
} | ||
|
||
return $isOpen; | ||
}); | ||
} | ||
|
||
/** | ||
* Stop the web server process once complete. | ||
*/ | ||
protected function tearDown(): void | ||
{ | ||
$this->process->stop(); | ||
} | ||
|
||
/** | ||
* This test will run after the web server is started. | ||
*/ | ||
public function testPactVerifyConsumer() | ||
{ | ||
$config = new VerifierConfig(); | ||
$config->getProviderInfo() | ||
->setName('jsonProvider') // Providers name to fetch. | ||
->setHost('localhost') | ||
->setPort(7202); | ||
$config->getProviderState() | ||
->setStateChangeUrl(new Uri('http://localhost:7202/pact-change-state')) | ||
; | ||
if ($level = \getenv('PACT_LOGLEVEL')) { | ||
$config->setLogLevel($level); | ||
} | ||
|
||
$verifier = new Verifier($config); | ||
$verifier->addFile(__DIR__ . '/../../pacts/jsonConsumer-jsonProvider.json'); | ||
|
||
$verifyResult = $verifier->verify(); | ||
|
||
$this->assertTrue($verifyResult); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="../../../vendor/autoload.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="PhpPact Example Tests"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="PACT_LOGLEVEL" value="DEBUG"/> | ||
</php> | ||
</phpunit> |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
example/src/MessageConsumer/receive.php → example/message/consumer/src/receive.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.