From 8a1f6db03657fc6aedfdb8ffefce7bd27aa960ab Mon Sep 17 00:00:00 2001 From: tienvx Date: Tue, 3 Jan 2023 22:38:12 +0700 Subject: [PATCH] Use Rust FFI: Stub Server --- README.md | 4 +- composer.json | 21 +- .../Standalone/Installer/Model/Scripts.php | 9 +- .../Service/StubServerHttpService.php | 4 +- .../Standalone/StubService/StubServer.php | 73 ++++- .../StubService/StubServerConfig.php | 294 +++++++++++++++--- .../StubService/StubServerConfigInterface.php | 202 ++++++++++-- .../Service/StubServerHttpServiceTest.php | 12 +- .../StubServer/StubServerConfigTest.php | 60 +++- .../Standalone/StubServer/StubServerTest.php | 6 +- 10 files changed, 583 insertions(+), 102 deletions(-) diff --git a/README.md b/README.md index c34cd5d0e..9db9fc453 100644 --- a/README.md +++ b/README.md @@ -385,13 +385,11 @@ If you would like to test with fixtures, you can use the `pact-stub-service` lik ```php $pactLocation = __DIR__ . '/someconsumer-someprovider.json'; -$host = 'localhost'; $port = 7201; $endpoint = 'test'; $config = (new StubServerConfig()) - ->setPactLocation($pactLocation) - ->setHost($host) + ->setFiles($pactLocation) ->setPort($port) ->setEndpoint($endpoint); diff --git a/composer.json b/composer.json index 5c0748795..bd15c25a1 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "amphp/process": "^1.1.1", "guzzlehttp/guzzle": "^6.5.8|^7.4.5", "phpunit/phpunit": ">=8.5.23 <10", - "tienvx/composer-downloads-plugin": "^1.1.0" + "tienvx/composer-downloads-plugin": "^1.2.0" }, "require-dev": { "roave/security-advisories": "dev-latest", @@ -77,10 +77,15 @@ "variables": { "{$os}": "PHP_OS_FAMILY === 'Windows' ? 'win32' : (PHP_OS === 'Darwin' ? 'osx' : 'linux')", "{$architecture}": "PHP_OS === 'Linux' ? '-x86_64' : ''", - "{$extension}": "PHP_OS_FAMILY === 'Windows' ? 'zip' : 'tar.gz'" + "{$extension}": "PHP_OS_FAMILY === 'Windows' ? 'zip' : 'tar.gz'", + "{$keep}": "PHP_OS_FAMILY === 'Windows' ? 'pact-broker.bat' : 'pact-broker'" }, "url": "https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v{$version}/pact-{$version}-{$os}{$architecture}.{$extension}", - "path": "bin/pact-ruby-standalone" + "path": "bin/pact-ruby-standalone", + "ignore": [ + "bin/*", + "!bin/{$keep}" + ] }, "pact-ffi-headers": { "version": "0.4.1", @@ -97,6 +102,16 @@ }, "url": "https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v{$version}/{$prefix}-{$os}-{$architecture}.{$extension}.gz", "path": "bin/pact-ffi-lib/pact.{$extension}" + }, + "pact-stub-server": { + "version": "0.5.2", + "variables": { + "{$os}": "PHP_OS === 'Darwin' ? 'osx' : strtolower(PHP_OS_FAMILY)", + "{$extension}": "PHP_OS_FAMILY === 'Windows' ? '.exe' : ''" + }, + "url": "https://github.com/pact-foundation/pact-stub-server/releases/download/v{$version}/pact-stub-server-{$os}-x86_64{$extension}.gz", + "path": "bin/pact-stub-server/pact-stub-server{$extension}", + "executable": true } } }, diff --git a/src/PhpPact/Standalone/Installer/Model/Scripts.php b/src/PhpPact/Standalone/Installer/Model/Scripts.php index a46ec5665..29efee7cf 100644 --- a/src/PhpPact/Standalone/Installer/Model/Scripts.php +++ b/src/PhpPact/Standalone/Installer/Model/Scripts.php @@ -40,7 +40,7 @@ public static function getLibrary(): string */ public static function getStubService(): string { - return self::$destinationDir . '/bin/pact-ruby-standalone/bin/pact-stub-service' . self::getSuffix(); + return self::$destinationDir . '/bin/pact-stub-server/pact-stub-server' . (PHP_OS_FAMILY === 'Windows' ? '.exe' : ''); } /** @@ -48,11 +48,6 @@ public static function getStubService(): string */ public static function getBroker(): string { - return self::$destinationDir . '/bin/pact-ruby-standalone/bin/pact-broker' . self::getSuffix(); - } - - private static function getSuffix(): string - { - return (PHP_OS_FAMILY === 'Windows' ? '.bat' : ''); + return self::$destinationDir . '/bin/pact-ruby-standalone/bin/pact-broker' . (PHP_OS_FAMILY === 'Windows' ? '.bat' : ''); } } diff --git a/src/PhpPact/Standalone/StubService/Service/StubServerHttpService.php b/src/PhpPact/Standalone/StubService/Service/StubServerHttpService.php index b3b98fed6..a96cfdd97 100644 --- a/src/PhpPact/Standalone/StubService/Service/StubServerHttpService.php +++ b/src/PhpPact/Standalone/StubService/Service/StubServerHttpService.php @@ -17,12 +17,12 @@ class StubServerHttpService implements StubServerHttpServiceInterface /** * @var ClientInterface */ - private $client; + private ClientInterface $client; /** * @var StubServerConfigInterface */ - private $config; + private StubServerConfigInterface $config; /** * StubServerHttpService constructor. diff --git a/src/PhpPact/Standalone/StubService/StubServer.php b/src/PhpPact/Standalone/StubService/StubServer.php index ff474b2c6..bcd4911ac 100644 --- a/src/PhpPact/Standalone/StubService/StubServer.php +++ b/src/PhpPact/Standalone/StubService/StubServer.php @@ -2,6 +2,7 @@ namespace PhpPact\Standalone\StubService; +use Amp\Process\ProcessException; use Exception; use PhpPact\Standalone\Installer\Model\Scripts; use PhpPact\Standalone\Runner\ProcessRunner; @@ -13,14 +14,14 @@ class StubServer { /** @var StubServerConfigInterface */ - private $config; + private StubServerConfigInterface $config; /** @var ProcessRunner */ - private $processRunner; + private ProcessRunner $processRunner; public function __construct(StubServerConfigInterface $config) { - $this->config = $config; + $this->config = $config; } /** @@ -32,7 +33,7 @@ public function __construct(StubServerConfigInterface $config) * * @return int process ID of the started Stub Server */ - public function start($wait = 1): int + public function start(int $wait = 1): int { $this->processRunner = new ProcessRunner(Scripts::getStubService(), $this->getArguments()); @@ -45,6 +46,8 @@ public function start($wait = 1): int /** * Stop the Stub Server process. * + * @throws ProcessException + * * @return bool Was stopping successful? */ public function stop(): bool @@ -61,12 +64,64 @@ private function getArguments(): array { $results = []; - $results[] = $this->config->getPactLocation(); - $results[] = "--host={$this->config->getHost()}"; - $results[] = "--port={$this->config->getPort()}"; + if ($this->config->getBrokerUrl() !== null) { + $results[] = "--broker-url={$this->config->getBrokerUrl()}"; + } + + foreach ($this->config->getDirs() as $dir) { + $results[] = "--dir={$dir}"; + } + + if ($this->config->getExtension() !== null) { + $results[] = "--extension={$this->config->getExtension()}"; + } + + foreach ($this->config->getFiles() as $file) { + $results[] = "--file={$file}"; + } + + if ($this->config->getLogLevel() !== null) { + $results[] = "--loglevel={$this->config->getLogLevel()}"; + } + + if ($this->config->getPort() !== null) { + $results[] = "--port={$this->config->getPort()}"; + } + + if ($this->config->getProviderState() !== null) { + $results[] = "--provider-state={$this->config->getProviderState()}"; + } + + if ($this->config->getProviderStateHeaderName() !== null) { + $results[] = "--provider-state-header-name={$this->config->getProviderStateHeaderName()}"; + } + + if ($this->config->getToken() !== null) { + $results[] = "--token={$this->config->getToken()}"; + } + + foreach ($this->config->getUrls() as $url) { + $results[] = "--url={$url}"; + } + + if ($this->config->getUser() !== null) { + $results[] = "--user={$this->config->getUser()}"; + } + + if ($this->config->isCors()) { + $results[] = '--cors'; + } + + if ($this->config->isCorsReferer()) { + $results[] = '--cors-referer'; + } + + if ($this->config->isEmptyProviderState()) { + $results[] = '--empty-provider-state'; + } - if ($this->config->getLog() !== null) { - $results[] = "--log={$this->config->getLog()}"; + if ($this->config->isInsecureTls()) { + $results[] = '--insecure-tls'; } return $results; diff --git a/src/PhpPact/Standalone/StubService/StubServerConfig.php b/src/PhpPact/Standalone/StubService/StubServerConfig.php index 0b179366a..0d54cc57d 100644 --- a/src/PhpPact/Standalone/StubService/StubServerConfig.php +++ b/src/PhpPact/Standalone/StubService/StubServerConfig.php @@ -11,49 +11,107 @@ */ class StubServerConfig implements StubServerConfigInterface { + private ?UriInterface $brokerUrl = null; + private ?int $port = null; + + private ?string $extension = null; + private ?string $logLevel = null; + private ?string $providerState = null; + private ?string $providerStateHeaderName = null; + private ?string $token = null; + private ?string $user = null; + + private array $dirs = []; + private array $files = []; + private array $urls = []; + private array $consumerNames = []; + private array $providerNames = []; + + private bool $cors = false; + private bool $corsReferer = false; + private bool $emptyProviderState = false; + private bool $insecureTls = false; + + private string $endpoint; + + /** + * {@inheritdoc} + */ + public function getBrokerUrl(): ?UriInterface + { + return $this->brokerUrl; + } + + /** + * {@inheritdoc} + */ + public function setBrokerUrl(UriInterface $brokerUrl): StubServerConfigInterface + { + $this->brokerUrl = $brokerUrl; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setDirs(string ...$dirs): StubServerConfigInterface + { + $this->dirs = $dirs; + + return $this; + } + /** - * Host on which to bind the service. - * - * @var string + * {@inheritdoc} */ - private $host = 'localhost'; + public function getDirs(): array + { + return $this->dirs; + } /** - * Port on which to run the service. - * - * @var int + * {@inheritdoc} */ - private $port = 7201; + public function getExtension(): ?string + { + return $this->extension; + } /** - * @var bool + * {@inheritdoc} */ - private $secure = false; + public function setExtension(string $extension): StubServerConfigInterface + { + $this->extension = $extension; + + return $this; + } /** - * File to which to log output. - * - * @var string + * {@inheritdoc} */ - private $log; + public function setFiles(string ...$files): StubServerConfigInterface + { + $this->files = $files; - private $pactLocation; - private $endpoint; + return $this; + } /** * {@inheritdoc} */ - public function getHost(): string + public function getFiles(): array { - return $this->host; + return $this->files; } /** * {@inheritdoc} */ - public function setHost(string $host): StubServerConfigInterface + public function setLogLevel(string $logLevel): StubServerConfigInterface { - $this->host = $host; + $this->logLevel = $logLevel; return $this; } @@ -61,7 +119,15 @@ public function setHost(string $host): StubServerConfigInterface /** * {@inheritdoc} */ - public function getPort(): int + public function getLogLevel(): ?string + { + return $this->logLevel; + } + + /** + * {@inheritdoc} + */ + public function getPort(): ?int { return $this->port; } @@ -79,17 +145,17 @@ public function setPort(int $port): StubServerConfigInterface /** * {@inheritdoc} */ - public function isSecure(): bool + public function getProviderState(): ?string { - return $this->secure; + return $this->providerState; } /** * {@inheritdoc} */ - public function setSecure(bool $secure): StubServerConfigInterface + public function setProviderState(string $providerState): StubServerConfigInterface { - $this->secure = $secure; + $this->providerState = $providerState; return $this; } @@ -97,49 +163,203 @@ public function setSecure(bool $secure): StubServerConfigInterface /** * {@inheritdoc} */ - public function getBaseUri(): UriInterface + public function getProviderStateHeaderName(): ?string + { + return $this->providerStateHeaderName; + } + + /** + * {@inheritdoc} + */ + public function setProviderStateHeaderName(string $providerStateHeaderName): StubServerConfigInterface { - $protocol = $this->secure ? 'https' : 'http'; + $this->providerStateHeaderName = $providerStateHeaderName; - return new Uri("{$protocol}://{$this->getHost()}:{$this->getPort()}"); + return $this; } /** * {@inheritdoc} */ - public function getLog() + public function getToken(): ?string { - return $this->log; + return $this->token; } /** * {@inheritdoc} */ - public function setLog(string $log): StubServerConfigInterface + public function setToken(?string $token): StubServerConfigInterface { - $this->log = $log; + $this->token = $token; return $this; } - public function getPactLocation(): string + /** + * {@inheritdoc} + */ + public function setUrls(string ...$urls): StubServerConfigInterface { - return $this->pactLocation; + $this->urls = $urls; + + return $this; } - public function setPactLocation(string $location) + /** + * {@inheritdoc} + */ + public function getUrls(): array { - $this->pactLocation = $location; + return $this->urls; + } + + /** + * {@inheritdoc} + */ + public function getUser(): ?string + { + return $this->user; + } + + /** + * {@inheritdoc} + */ + public function setUser(string $user): StubServerConfigInterface + { + $this->user = $user; return $this; } + /** + * {@inheritdoc} + */ + public function isCors(): bool + { + return $this->cors; + } + + /** + * {@inheritdoc} + */ + public function setCors(bool $cors): StubServerConfigInterface + { + $this->cors = $cors; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function isCorsReferer(): bool + { + return $this->corsReferer; + } + + /** + * {@inheritdoc} + */ + public function setCorsReferer(bool $corsReferer): StubServerConfigInterface + { + $this->corsReferer = $corsReferer; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function isEmptyProviderState(): bool + { + return $this->emptyProviderState; + } + + /** + * {@inheritdoc} + */ + public function setEmptyProviderState(bool $emptyProviderState): StubServerConfigInterface + { + $this->emptyProviderState = $emptyProviderState; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function isInsecureTls(): bool + { + return $this->insecureTls; + } + + /** + * {@inheritdoc} + */ + public function setInsecureTls(bool $insecureTls): StubServerConfigInterface + { + $this->insecureTls = $insecureTls; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setConsumerNames(string ...$consumerNames): StubServerConfigInterface + { + $this->consumerNames = $consumerNames; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getConsumerNames(): array + { + return $this->consumerNames; + } + + /** + * {@inheritdoc} + */ + public function setProviderNames(string ...$providerNames): StubServerConfigInterface + { + $this->providerNames = $providerNames; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getProviderNames(): array + { + return $this->providerNames; + } + + /** + * {@inheritdoc} + */ + public function getBaseUri(): UriInterface + { + return new Uri("http://localhost:{$this->getPort()}"); + } + + /** + * {@inheritdoc} + */ public function getEndpoint(): string { return $this->endpoint; } - public function setEndpoint(string $endpoint) + /** + * {@inheritdoc} + */ + public function setEndpoint(string $endpoint): StubServerConfigInterface { $this->endpoint = $endpoint; diff --git a/src/PhpPact/Standalone/StubService/StubServerConfigInterface.php b/src/PhpPact/Standalone/StubService/StubServerConfigInterface.php index 2585fd889..dd2848fa8 100644 --- a/src/PhpPact/Standalone/StubService/StubServerConfigInterface.php +++ b/src/PhpPact/Standalone/StubService/StubServerConfigInterface.php @@ -11,63 +11,225 @@ interface StubServerConfigInterface { /** - * @return string the host of the stub service + * @return null|UriInterface url to the pact broker */ - public function getHost(): string; + public function getBrokerUrl(): ?UriInterface; /** - * @param string $host The host of the stub service + * URL of the pact broker to fetch pacts from + * + * @param UriInterface $brokerUrl + * + * @return StubServerConfigInterface + */ + public function setBrokerUrl(UriInterface $brokerUrl): self; + + /** + * @param string ...$dirs Directory of pact files to load * * @return StubServerConfigInterface */ - public function setHost(string $host): self; + public function setDirs(string ...$dirs): self; /** - * @return int the port of the stub service + * @return array */ - public function getPort(): int; + public function getDirs(): array; /** - * @param int $port the port of the stub service + * @return null|string + */ + public function getExtension(): ?string; + + /** + * @param string $extension File extension to use when loading from a directory (default is json) + * + * @return StubServerConfigInterface + */ + public function setExtension(string $extension): self; + + /** + * @param string ...$files Pact file to load + * + * @return StubServerConfigInterface + */ + public function setFiles(string ...$files): self; + + /** + * @return array + */ + public function getFiles(): array; + + /** + * @return null|string + */ + public function getLogLevel(): ?string; + + /** + * @param string $logLevel Log level (defaults to info) [possible values: error, warn, info, debug, trace, none] + * + * @return StubServerConfigInterface + */ + public function setLogLevel(string $logLevel): self; + + /** + * @return null|int the port of the stub service + */ + public function getPort(): ?int; + + /** + * @param int $port Port to run on (defaults to random port assigned by the OS) * * @return StubServerConfigInterface */ public function setPort(int $port): self; /** - * @return bool true if https + * @return null|string state of the provider */ - public function isSecure(): bool; + public function getProviderState(): ?string; /** - * @param bool $secure set to true for https + * @param string $providerState Provider state regular expression to filter the responses by * * @return StubServerConfigInterface */ - public function setSecure(bool $secure): self; + public function setProviderState(string $providerState): self; /** - * @return UriInterface + * @return null|string name of the header */ - public function getBaseUri(): UriInterface; + public function getProviderStateHeaderName(): ?string; + + /** + * @param string $providerStateHeaderName Name of the header parameter containing the provider state to be used in case multiple matching interactions are found + * + * @return StubServerConfigInterface + */ + public function setProviderStateHeaderName(string $providerStateHeaderName): self; + + /** + * @return null|string token for the pact broker + */ + public function getToken(): ?string; /** - * @return string directory for log output + * @param null|string $token Bearer token to use when fetching pacts from URLS or Pact Broker + * + * @return StubServerConfigInterface */ - public function getLog(); + public function setToken(?string $token): self; /** - * @param string $log directory for log output + * @param string ...$urls URL of pact file to fetch * * @return StubServerConfigInterface */ - public function setLog(string $log): self; + public function setUrls(string ...$urls): self; + + /** + * @return array + */ + public function getUrls(): array; + + /** + * @return null|string user and password + */ + public function getUser(): ?string; - public function getPactLocation(): string; + /** + * @param string $user User and password to use when fetching pacts from URLS or Pact Broker in user:password form + * + * @return StubServerConfigInterface + */ + public function setUser(string $user): self; - public function setPactLocation(string $location); + /** + * @return bool + */ + public function isCors(): bool; + /** + * @param bool $cors + * + * @return StubServerConfigInterface + */ + public function setCors(bool $cors): self; + + /** + * @return bool + */ + public function isCorsReferer(): bool; + + /** + * @param bool $corsReferer + * + * @return StubServerConfigInterface + */ + public function setCorsReferer(bool $corsReferer): self; + + /** + * @return bool + */ + public function isEmptyProviderState(): bool; + + /** + * @param bool $emptyProviderState + * + * @return StubServerConfigInterface + */ + public function setEmptyProviderState(bool $emptyProviderState): self; + + /** + * @return bool + */ + public function isInsecureTls(): bool; + + /** + * @param bool $insecureTls + * + * @return StubServerConfigInterface + */ + public function setInsecureTls(bool $insecureTls): self; + + /** + * @param string ...$consumerNames Consumer name to use to filter the Pacts fetched from the Pact broker + * + * @return StubServerConfigInterface + */ + public function setConsumerNames(string ...$consumerNames): self; + + /** + * @return array + */ + public function getConsumerNames(): array; + + /** + * @param string ...$providerNames Provider name to use to filter the Pacts fetched from the Pact broker + * + * @return StubServerConfigInterface + */ + public function setProviderNames(string ...$providerNames): self; + + /** + * @return array + */ + public function getProviderNames(): array; + + /** + * @return UriInterface + */ + public function getBaseUri(): UriInterface; + + /** + * @return string + */ public function getEndpoint(): string; - public function setEndpoint(string $location); + /** + * @param string $endpoint + * + * @return StubServerConfigInterface + */ + public function setEndpoint(string $endpoint): self; } diff --git a/tests/PhpPact/Standalone/StubServer/Service/StubServerHttpServiceTest.php b/tests/PhpPact/Standalone/StubServer/Service/StubServerHttpServiceTest.php index bc580efaa..0bd0dd9ca 100644 --- a/tests/PhpPact/Standalone/StubServer/Service/StubServerHttpServiceTest.php +++ b/tests/PhpPact/Standalone/StubServer/Service/StubServerHttpServiceTest.php @@ -14,13 +14,13 @@ class StubServerHttpServiceTest extends TestCase { /** @var StubServerHttpServiceInterface */ - private $service; + private StubServerHttpServiceInterface $service; /** @var StubServer */ - private $stubServer; + private StubServer $stubServer; /** @var StubServerConfigInterface */ - private $config; + private StubServerConfigInterface $config; /** * @throws MissingEnvVariableException @@ -29,18 +29,16 @@ class StubServerHttpServiceTest extends TestCase protected function setUp(): void { $pactLocation = __DIR__ . '/../../../../_resources/someconsumer-someprovider.json'; - $host = 'localhost'; $port = 7201; $endpoint = 'test'; $this->config = (new StubServerConfig()) - ->setPactLocation($pactLocation) - ->setHost($host) + ->setFiles($pactLocation) ->setPort($port) ->setEndpoint($endpoint); $this->stubServer = new StubServer($this->config); - $this->stubServer->start(10); + $this->stubServer->start(); $this->service = new StubServerHttpService(new GuzzleClient(), $this->config); } diff --git a/tests/PhpPact/Standalone/StubServer/StubServerConfigTest.php b/tests/PhpPact/Standalone/StubServer/StubServerConfigTest.php index db9aed123..8e7cea03b 100644 --- a/tests/PhpPact/Standalone/StubServer/StubServerConfigTest.php +++ b/tests/PhpPact/Standalone/StubServer/StubServerConfigTest.php @@ -2,6 +2,7 @@ namespace PhpPactTest\Standalone\StubServer; +use GuzzleHttp\Psr7\Uri; use PhpPact\Standalone\StubService\StubServerConfig; use PHPUnit\Framework\TestCase; @@ -9,20 +10,59 @@ class StubServerConfigTest extends TestCase { public function testSetters() { - $pactLocation = __DIR__ . '/../../../_resources/someconsumer-someprovider.json'; - $host = 'test-host'; - $port = 1234; - $log = 'test-log-dir/'; + $brokerUrl = new Uri('http://localhost'); + $port = 1234; + $extension = 'json'; + $logLevel = 'debug'; + $providerState = 'state'; + $providerStateHeaderName = 'header'; + $token = 'token'; + $user = 'user:password'; + $pactLocation = __DIR__ . '/../../../_resources'; + $files = ['/path/to/pact.json']; + $urls = ['http://example.com/path/to/file.json']; + $consumerNames = ['consumer-1', 'consumer-2']; + $providerNames = ['provider-1', 'provider-2']; + $cors = true; + $corsReferer = true; + $emptyProviderState = true; + $insecureTls = true; $subject = (new StubServerConfig()) - ->setPactLocation($pactLocation) - ->setHost($host) + ->setBrokerUrl($brokerUrl) ->setPort($port) - ->setLog($log); + ->setExtension($extension) + ->setLogLevel($logLevel) + ->setProviderState($providerState) + ->setProviderStateHeaderName($providerStateHeaderName) + ->setToken($token) + ->setUser($user) + ->setDirs($pactLocation) + ->setFiles(...$files) + ->setUrls(...$urls) + ->setConsumerNames(...$consumerNames) + ->setProviderNames(...$providerNames) + ->setCors($cors) + ->setCorsReferer($corsReferer) + ->setEmptyProviderState($emptyProviderState) + ->setInsecureTls($insecureTls); - static::assertSame($pactLocation, $subject->getPactLocation()); - static::assertSame($host, $subject->getHost()); + static::assertSame($brokerUrl, $subject->getBrokerUrl()); static::assertSame($port, $subject->getPort()); - static::assertSame($log, $subject->getLog()); + static::assertSame($extension, $subject->getExtension()); + static::assertSame($logLevel, $subject->getLogLevel()); + static::assertSame($providerState, $subject->getProviderState()); + static::assertSame($providerStateHeaderName, $subject->getProviderStateHeaderName()); + static::assertSame($token, $subject->getToken()); + static::assertSame($user, $subject->getUser()); + static::assertSame([$pactLocation], $subject->getDirs()); + static::assertSame($files, $subject->getFiles()); + static::assertSame($urls, $subject->getUrls()); + static::assertSame($consumerNames, $subject->getConsumerNames()); + static::assertSame($providerNames, $subject->getProviderNames()); + static::assertSame($cors, $subject->isCors()); + static::assertSame($corsReferer, $subject->isCorsReferer()); + static::assertSame($emptyProviderState, $subject->isEmptyProviderState()); + static::assertSame($insecureTls, $subject->isInsecureTls()); } } diff --git a/tests/PhpPact/Standalone/StubServer/StubServerTest.php b/tests/PhpPact/Standalone/StubServer/StubServerTest.php index 963fabf8d..3fb609fa0 100644 --- a/tests/PhpPact/Standalone/StubServer/StubServerTest.php +++ b/tests/PhpPact/Standalone/StubServer/StubServerTest.php @@ -15,15 +15,13 @@ public function testStartAndStop() { try { $pactLocation = __DIR__ . '/../../../_resources/someconsumer-someprovider.json'; - $host = 'localhost'; $port = 7201; $endpoint = 'test'; $subject = (new StubServerConfig()) - ->setPactLocation($pactLocation) - ->setHost($host) + ->setFiles($pactLocation) ->setPort($port) - ->setEndpoint($endpoint); + ->setEndpoint($endpoint); $stubServer = new StubServer($subject); $pid = $stubServer->start();