diff --git a/appveyor.yml b/appveyor.yml index 1bf26491..717f72f0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,6 +33,8 @@ build: off test_script: - cmd: C:\tools\php71\php.exe .\vendor\phpunit\phpunit\phpunit -c .\phpunit-all-tests.xml + - appveyor DownloadFile http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar + - cmd: C:\tools\php71\php.exe php-cs-fixer-v2.phar fix -v --dry-run --stop-on-violation --using-cache=no . on_success: - echo Success @@ -41,12 +43,7 @@ on_failure: - echo Failure notifications: - - provider: Webhook - url: - secure: c4xwvfA2YpTyASkpasFt2vA6q4pCxCMoWhfX9/JwBxp6rub4dphj6smGxy+5rnsHcvVU6/FvzVHQo4hoxL5gOA== - on_build_success: false - on_build_failure: true - on_build_status_changed: true + # Email # - provider: Email # to: diff --git a/example/site/provider.php b/example/site/provider.php index ac73e27c..c9b2ee78 100644 --- a/example/site/provider.php +++ b/example/site/provider.php @@ -1,44 +1,44 @@ id = 100 + $i; - $obj->name = sprintf("Type %d", $obj->id); - - $objects[] = $obj; - } - - $ret = new \stdClass(); - $ret->types = $objects; - return $ret; -} \ No newline at end of file +function generate($objCount = 3) +{ + $objects = array(); + + for ($i=0;$i<$objCount;$i++) { + $obj = new \stdClass(); + $obj->id = 100 + $i; + $obj->name = sprintf("Type %d", $obj->id); + + $objects[] = $obj; + } + + $ret = new \stdClass(); + $ret->types = $objects; + return $ret; +} diff --git a/example/test/ConsumerTest.php b/example/test/ConsumerTest.php index 3e007aa4..82b8dfb8 100644 --- a/example/test/ConsumerTest.php +++ b/example/test/ConsumerTest.php @@ -1,6 +1,6 @@ VerifyInteractions(); - } catch (\PhpPact\PactFailureException $e) { $hasException = true; } @@ -216,7 +215,6 @@ public function testGetWithMultipleRequests() $receivedBodyResponse = $clientUnderTest->GetWithBody("http://localhost"); $receivedPathResponse = $clientUnderTest->GetWithPath("http://localhost"); - } catch (\PhpPact\PactFailureException $e) { $hasException = true; } diff --git a/example/test/MockApiConsumer.php b/example/test/MockApiConsumer.php index ae7e7eba..ea9bdc97 100644 --- a/example/test/MockApiConsumer.php +++ b/example/test/MockApiConsumer.php @@ -133,4 +133,4 @@ private function sendRequest(\Psr\Http\Message\RequestInterface $httpRequest) // make actual call to the client throw new \Exception("Since this is a mock api client, there is no 'real' server. This is where you put your app logic."); } -} \ No newline at end of file +} diff --git a/example/test/ProviderTest.php b/example/test/ProviderTest.php index c737b040..7c361870 100644 --- a/example/test/ProviderTest.php +++ b/example/test/ProviderTest.php @@ -6,10 +6,9 @@ final class ProviderTest extends TestCase { - - public function testServerExists() { - - $http = new \Windwalker\Http\HttpClient(); + public function testServerExists() + { + $http = new \Windwalker\Http\HttpClient(); $uri = 'http://' . WEB_SERVER_HOST . ':' . WEB_SERVER_PORT . '/provider.php'; $response = $http->get($uri); @@ -18,8 +17,8 @@ public function testServerExists() { $this->assertEquals(200, (int) $status, "Expect a 200 status code"); } - public function testPactProvider() { - + public function testPactProvider() + { $uri = WEB_SERVER_HOST . ':' . WEB_SERVER_PORT; $httpClient = new \Windwalker\Http\HttpClient(); @@ -27,10 +26,9 @@ public function testPactProvider() { $pactVerifier = new \PhpPact\PactVerifier($uri); $hasException = false; try { + $json = $this->getPactRoot() . DIRECTORY_SEPARATOR . 'mockapiconsumer-mockapiprovider.json'; - $json = $this->getPactRoot() . DIRECTORY_SEPARATOR . 'mockapiconsumer-mockapiprovider.json'; - - $pactVerifier->ProviderState("Test State") + $pactVerifier->ProviderState("Test State") ->ServiceProvider("MockApiProvider", $httpClient) ->HonoursPactWith("MockApiConsumer") ->PactUri($json) @@ -39,15 +37,14 @@ public function testPactProvider() { $pactVerifier->Verify(null, "A GET request to get variable types"); $pactVerifier->Verify(null, "There is something to POST to"); - - }catch(\PhpPact\PactFailureException $e) { + } catch (\PhpPact\PactFailureException $e) { $hasException = true; } $this->assertFalse($hasException, "Expect Pact to validate."); } - public function testPactProviderStateSetupTearDown() { - + public function testPactProviderStateSetupTearDown() + { $uri = WEB_SERVER_HOST . ':' . WEB_SERVER_PORT; $httpClient = new \Windwalker\Http\HttpClient(); @@ -55,10 +52,10 @@ public function testPactProviderStateSetupTearDown() { $pactVerifier = new \PhpPact\PactVerifier($uri); $hasException = false; - $setUpFunction = function() { + $setUpFunction = function () { $fileName = "mock.json"; $currentDir = dirname(__FILE__); - $absolutePath = realpath($currentDir . '/../site/' ); + $absolutePath = realpath($currentDir . '/../site/'); $absolutePath .= '/' . $fileName; $type = new \stdClass(); @@ -74,10 +71,10 @@ public function testPactProviderStateSetupTearDown() { file_put_contents($absolutePath, $output); }; - $tearDownFunction = function() { + $tearDownFunction = function () { $fileName = "mock.json"; $currentDir = dirname(__FILE__); - $absolutePath = realpath($currentDir . '/../site/' ); + $absolutePath = realpath($currentDir . '/../site/'); $absolutePath .= '/' . $fileName; unlink($absolutePath); @@ -91,16 +88,15 @@ public function testPactProviderStateSetupTearDown() { ->HonoursPactWith("MockApiConsumer") ->PactUri($json) ->Verify(); // note that this should test all as we can run setup and tear down - - }catch(\PhpPact\PactFailureException $e) { + } catch (\PhpPact\PactFailureException $e) { $hasException = true; } $this->assertFalse($hasException, "Expect Pact to validate."); } - private function getPactRoot() - { - $dir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'pact' . DIRECTORY_SEPARATOR; - return realpath($dir); - } -} \ No newline at end of file + private function getPactRoot() + { + $dir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'pact' . DIRECTORY_SEPARATOR; + return realpath($dir); + } +} diff --git a/example/test/autoload.php b/example/test/autoload.php index 56be2190..3e2406d5 100644 --- a/example/test/autoload.php +++ b/example/test/autoload.php @@ -20,4 +20,4 @@ function pact_php_example_autoloader($className) } } -spl_autoload_register('pact_php_example_autoloader'); \ No newline at end of file +spl_autoload_register('pact_php_example_autoloader'); diff --git a/example/test/bootstrap.php b/example/test/bootstrap.php index 556deb99..7fadcccd 100644 --- a/example/test/bootstrap.php +++ b/example/test/bootstrap.php @@ -12,25 +12,25 @@ $command = CraftCommand(WEB_SERVER_HOST, WEB_SERVER_PORT, WEB_SERVER_DOCROOT); $phandle = popen($command, "r"); -$read = stream_get_contents($phandle); //Read the output +$read = stream_get_contents($phandle); //Read the output pclose($phandle); - + $i = 0; $pid = ExtractProcessIdFromWMIC($read); echo sprintf( - '%s - Web server started on %s:%d with PID %d', + '%s - Web server started on %s:%d with PID %d', date('r'), - WEB_SERVER_HOST, - WEB_SERVER_PORT, + WEB_SERVER_HOST, + WEB_SERVER_PORT, $pid ) . PHP_EOL; // Kill the web server when the process ends -register_shutdown_function(function() use ($pid) { - sleep(1); // sleep for a few seconds before shutting down - echo sprintf('%s - Killing process with ID %d', date('r'), $pid) . PHP_EOL; - shell_exec("taskkill /F /PID $pid"); +register_shutdown_function(function () use ($pid) { + sleep(1); // sleep for a few seconds before shutting down + echo sprintf('%s - Killing process with ID %d', date('r'), $pid) . PHP_EOL; + shell_exec("taskkill /F /PID $pid"); }); /*********************************************** @@ -39,43 +39,44 @@ * ***********************************************/ -function CraftCommand($host, $port, $docroot) +function CraftCommand($host, $port, $docroot) { - $php = PHP_BINARY; - $fullroot = getcwd() . "/" . $docroot; - $fullroot = str_replace("\\", "/", $fullroot); - //PrintDirectory($fullroot); - - $command = "wmic process call create \"$php -S $host:$port -t $fullroot \""; + $php = PHP_BINARY; + $fullroot = getcwd() . "/" . $docroot; + $fullroot = str_replace("\\", "/", $fullroot); + //PrintDirectory($fullroot); + + $command = "wmic process call create \"$php -S $host:$port -t $fullroot \""; - return $command; + return $command; } -function ExtractProcessIdFromWMIC($read) +function ExtractProcessIdFromWMIC($read) { - $pid = false; - $output = explode("\n",$read); + $pid = false; + $output = explode("\n", $read); - foreach($output as $line) { - if (stripos($line, "ProcessId") !== false) { - $ex = explode("=", $line, 2); - $pid = trim($ex[1]); - $pid = substr($pid, 0, strlen($pid) - 1); // remove ; - return $pid; - } - } - - return $pid; + foreach ($output as $line) { + if (stripos($line, "ProcessId") !== false) { + $ex = explode("=", $line, 2); + $pid = trim($ex[1]); + $pid = substr($pid, 0, strlen($pid) - 1); // remove ; + return $pid; + } + } + + return $pid; } -function PrintDirectory($dir) { - if ($handle = opendir($dir)) { - while (false !== ($entry = readdir($handle))) { - if ($entry != "." && $entry != "..") { - echo "$entry\n"; - } - } - closedir($handle); - } +function PrintDirectory($dir) +{ + if ($handle = opendir($dir)) { + while (false !== ($entry = readdir($handle))) { + if ($entry != "." && $entry != "..") { + echo "$entry\n"; + } + } + closedir($handle); + } } -// More bootstrap code \ No newline at end of file +// More bootstrap code diff --git a/src/Comparers/ComparisonFailure.php b/src/Comparers/ComparisonFailure.php index c6f76585..3dd1edce 100644 --- a/src/Comparers/ComparisonFailure.php +++ b/src/Comparers/ComparisonFailure.php @@ -13,4 +13,4 @@ public function getResult() { return $this->_result; } -} \ No newline at end of file +} diff --git a/src/Comparers/ComparisonResult.php b/src/Comparers/ComparisonResult.php index fe38f829..98c8ae2d 100644 --- a/src/Comparers/ComparisonResult.php +++ b/src/Comparers/ComparisonResult.php @@ -65,5 +65,4 @@ public function AddChildResult(&$comparisonResult) $this->_childResults[] = $comparisonResult; } - -} \ No newline at end of file +} diff --git a/src/Comparers/DiffComparisonFailure.php b/src/Comparers/DiffComparisonFailure.php index a5253ac7..88f531df 100644 --- a/src/Comparers/DiffComparisonFailure.php +++ b/src/Comparers/DiffComparisonFailure.php @@ -8,4 +8,4 @@ public function __construct($expected, $actual, $message='') $msg = ($message ? sprintf("Message: %s", $message) : ''); $this->_result = sprintf("Expected: %s, Actual: %s. %s", ($expected ? print_r($expected, true) : "null"), ($actual ? print_r($actual, true) : "null"), $msg); } -} \ No newline at end of file +} diff --git a/src/Comparers/ErrorMessageComparisonFailure.php b/src/Comparers/ErrorMessageComparisonFailure.php index 6f40648c..d4347417 100644 --- a/src/Comparers/ErrorMessageComparisonFailure.php +++ b/src/Comparers/ErrorMessageComparisonFailure.php @@ -8,4 +8,4 @@ public function __construct($errorMessage) { $this->_result = $errorMessage; } -} \ No newline at end of file +} diff --git a/src/Comparers/IComparer.php b/src/Comparers/IComparer.php index f8c1bb3b..076bb412 100644 --- a/src/Comparers/IComparer.php +++ b/src/Comparers/IComparer.php @@ -5,4 +5,4 @@ interface IComparer { public function Compare($expected, $actual); -} \ No newline at end of file +} diff --git a/src/Comparers/MissingInteractionComparisonFailure.php b/src/Comparers/MissingInteractionComparisonFailure.php index 6b1d8a86..f5ff0b86 100644 --- a/src/Comparers/MissingInteractionComparisonFailure.php +++ b/src/Comparers/MissingInteractionComparisonFailure.php @@ -19,7 +19,8 @@ public function __construct($interaction) "The interaction with description '%s' and provider state '%s', was not used by the test. Missing request %s.", $interaction->getDescription(), $interaction->getProviderState(), - $this->_requestDescription); + $this->_requestDescription + ); } /** @@ -29,4 +30,4 @@ public function getRequestDescription() { return $this->_requestDescription; } -} \ No newline at end of file +} diff --git a/src/Comparers/UnexpectedRequestComparisonFailure.php b/src/Comparers/UnexpectedRequestComparisonFailure.php index e18790e5..3b02fe67 100644 --- a/src/Comparers/UnexpectedRequestComparisonFailure.php +++ b/src/Comparers/UnexpectedRequestComparisonFailure.php @@ -17,7 +17,8 @@ public function __construct($request) $this->_requestDescription = sprintf("%s %s", $requestMethod, $requestPath); $this->_result = sprintf( "An unexpected request %s was seen by the mock provider service.", - $this->_requestDescription); + $this->_requestDescription + ); } /** @@ -27,5 +28,4 @@ public function getRequestDescription() { return $this->_requestDescription; } - -} \ No newline at end of file +} diff --git a/src/Constants.php b/src/Constants.php index c304299b..b188a398 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -7,4 +7,4 @@ class Constants const DEFAULT_PACT_DIR = "D:/Temp/pact"; const DEFAULT_HOST = 'localhost'; const DEFAULT_PORT = '80'; -} \ No newline at end of file +} diff --git a/src/Extensions/StringExtensions.php b/src/Extensions/StringExtensions.php index 96caba46..6603926f 100644 --- a/src/Extensions/StringExtensions.php +++ b/src/Extensions/StringExtensions.php @@ -8,4 +8,4 @@ public static function ToLowerSnakeCase($input) { return (!$input ? strtolower(str_replace(' ', '_', $input)) : ''); } -} \ No newline at end of file +} diff --git a/src/IPactBuilder.php b/src/IPactBuilder.php index 948860a4..2242b1f9 100644 --- a/src/IPactBuilder.php +++ b/src/IPactBuilder.php @@ -3,7 +3,6 @@ interface IPactBuilder { - public function ServiceConsumer($consumerName); public function HasPactWith($providerName); @@ -11,4 +10,4 @@ public function HasPactWith($providerName); public function setMockService($providerName, \PhpPact\PactConfig $config); public function Build(); -} \ No newline at end of file +} diff --git a/src/IPactVerifier.php b/src/IPactVerifier.php index d7dcd2d6..3e927eac 100644 --- a/src/IPactVerifier.php +++ b/src/IPactVerifier.php @@ -13,11 +13,11 @@ interface IPactVerifier * @param $tearDown A tear down action that will be run after the interaction verify, if the provider has specified it in the interaction. If no action is required please namespace an empty lambda () => {} */ - function ServiceProvider($providerName, $httpClient, $httpRequestSender); + public function ServiceProvider($providerName, $httpClient, $httpRequestSender); - function HonoursPactWith($consumerName); + public function HonoursPactWith($consumerName); - function PactUri($uri, $options = null); + public function PactUri($uri, $options = null); - function Verify($description = null, $providerState = null); -} \ No newline at end of file + public function Verify($description = null, $providerState = null); +} diff --git a/src/Mappers/IMapper.php b/src/Mappers/IMapper.php index c6c212e2..25dc250c 100644 --- a/src/Mappers/IMapper.php +++ b/src/Mappers/IMapper.php @@ -5,4 +5,4 @@ interface IMapper { public function Convert($request); -} \ No newline at end of file +} diff --git a/src/Matchers/FailedMatcherCheck.php b/src/Matchers/FailedMatcherCheck.php index 2790ad3b..e1434056 100644 --- a/src/Matchers/FailedMatcherCheck.php +++ b/src/Matchers/FailedMatcherCheck.php @@ -27,4 +27,4 @@ public function setFailureType($failureType) { $this->_failureType = $failureType; } -} \ No newline at end of file +} diff --git a/src/Matchers/IMatcher.php b/src/Matchers/IMatcher.php index c3a0bbfe..be06a9b1 100644 --- a/src/Matchers/IMatcher.php +++ b/src/Matchers/IMatcher.php @@ -5,4 +5,4 @@ interface IMatcher { public function Match($path, $expected, $actual); -} \ No newline at end of file +} diff --git a/src/Matchers/MatcherCheck.php b/src/Matchers/MatcherCheck.php index 0f3ad355..04d49fc3 100644 --- a/src/Matchers/MatcherCheck.php +++ b/src/Matchers/MatcherCheck.php @@ -4,7 +4,6 @@ class MatcherCheck { - const PathPrefix = "$."; private $_path; @@ -29,4 +28,4 @@ public function setPath($path) $this->_path = $path; return $this; } -} \ No newline at end of file +} diff --git a/src/Matchers/MatcherCheckFailureType.php b/src/Matchers/MatcherCheckFailureType.php index 1dab3bbc..2114179b 100644 --- a/src/Matchers/MatcherCheckFailureType.php +++ b/src/Matchers/MatcherCheckFailureType.php @@ -2,8 +2,9 @@ namespace PhpPact\Matchers; -class MatcherCheckFailureType { - const AdditionalItemInArray = 'AdditionalItemInArray'; - const AdditionalPropertyInObject = 'AdditionalPropertyInObject'; - const ValueDoesNotMatch = 'ValueDoesNotMatch'; -} \ No newline at end of file +class MatcherCheckFailureType +{ + const AdditionalItemInArray = 'AdditionalItemInArray'; + const AdditionalPropertyInObject = 'AdditionalPropertyInObject'; + const ValueDoesNotMatch = 'ValueDoesNotMatch'; +} diff --git a/src/Matchers/MatcherResult.php b/src/Matchers/MatcherResult.php index d7167e57..ef5bb8ac 100644 --- a/src/Matchers/MatcherResult.php +++ b/src/Matchers/MatcherResult.php @@ -4,7 +4,6 @@ class MatcherResult { - private $_matcherChecks; public function __construct($matcherCheck) @@ -32,6 +31,4 @@ public function setMatcherChecks(array $matcherChecks) { $this->_matcherChecks = $matcherChecks; } - - -} \ No newline at end of file +} diff --git a/src/Matchers/SuccessfulMatcherCheck.php b/src/Matchers/SuccessfulMatcherCheck.php index 0f90316a..40e2510e 100644 --- a/src/Matchers/SuccessfulMatcherCheck.php +++ b/src/Matchers/SuccessfulMatcherCheck.php @@ -8,4 +8,4 @@ public function __construct($path) { $this->setPath($path); } -} \ No newline at end of file +} diff --git a/src/Mocks/IMockProvider.php b/src/Mocks/IMockProvider.php index 00330560..4e229421 100644 --- a/src/Mocks/IMockProvider.php +++ b/src/Mocks/IMockProvider.php @@ -1,11 +1,10 @@ ShouldSerializeBody() && $expected->getBody() == null && $actual->getBody()) - { + if ($expected->ShouldSerializeBody() && $expected->getBody() == null && $actual->getBody()) { $result->RecordFailure(new \PhpPact\Comparers\DiffComparisonFailure($expected, $actual)); return $result; } @@ -31,25 +30,22 @@ public function Compare($expected, $actual, $matchingRules) // looking for an exact match at the object level if (is_string($expected)) { $expected = $this->JsonDecode($expected); - } - else if (method_exists($expected, "getBody") && is_string($expected->getBody())) { + } elseif (method_exists($expected, "getBody") && is_string($expected->getBody())) { $expected = $this->JsonDecode($expected->getBody()); } if (is_string($actual)) { $actual = $this->JsonDecode($actual); - } - else if (method_exists($actual, "getBody") && is_string($actual->getBody())) { + } elseif (method_exists($actual, "getBody") && is_string($actual->getBody())) { $actual = $this->JsonDecode($actual->getBody()); } // cycle through matching rules - foreach($matchingRules as $matchingRuleKey => $matchingRule) { + foreach ($matchingRules as $matchingRuleKey => $matchingRule) { $results = $matchingRule->Match($matchingRuleKey, $expected, $actual); $checks = $results->getMatcherChecks(); - foreach($checks as $check) - { + foreach ($checks as $check) { if (($check instanceof \PhpPact\Matchers\FailedMatcherCheck)) { $result->RecordFailure(new \PhpPact\Comparers\DiffComparisonFailure($expected, $actual)); } @@ -72,4 +68,4 @@ private function JsonDecode($obj) } return $obj; } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Comparers/HttpHeaderComparer.php b/src/Mocks/MockHttpService/Comparers/HttpHeaderComparer.php index 343fd079..02cf5643 100644 --- a/src/Mocks/MockHttpService/Comparers/HttpHeaderComparer.php +++ b/src/Mocks/MockHttpService/Comparers/HttpHeaderComparer.php @@ -16,7 +16,6 @@ public function Compare($expected, $actual) $result = new \PhpPact\Comparers\ComparisonResult("includes headers"); if ($actual == null) { - $result->RecordFailure(new \PhpPact\Comparers\ErrorMessageComparisonFailure("Actual Headers are null")); return $result; } @@ -39,7 +38,7 @@ public function Compare($expected, $actual) $expectedKeywords = preg_split("/[\,;]+/", $header_value); - if (count($actualKeywords) == count($expectedKeywords) && count($actualKeywords) > 0){ + if (count($actualKeywords) == count($expectedKeywords) && count($actualKeywords) > 0) { $actualKeywords = array_map('trim', $actualKeywords); $expectedKeywords = array_map('trim', $expectedKeywords); @@ -47,8 +46,7 @@ public function Compare($expected, $actual) $failure = new \PhpPact\Comparers\DiffComparisonFailure($header_value, $actualValue); $headerResult->RecordFailure($failure); } - } - else if ($header_value != $actualValue) { + } elseif ($header_value != $actualValue) { $failure = new \PhpPact\Comparers\DiffComparisonFailure($header_value, $actualValue); $headerResult->RecordFailure($failure); } @@ -77,10 +75,11 @@ private function MakeArrayLowerCase($from) return $new; } - public function ObjectToArray ($object) + public function ObjectToArray($object) { - if (!is_object($object) && !is_array($object)) + if (!is_object($object) && !is_array($object)) { return $object; + } return array_map(array($this, 'ObjectToArray'), (array)$object); } @@ -94,13 +93,13 @@ public function ObjectToArray ($object) * @param $array2 * @return bool */ - private function array_diff_order( $array1, $array2 ) + private function array_diff_order($array1, $array2) { - while ((list($key1, $val1) = each($array1)) && (list($key2, $val2) = each($array2)) ) { - if($key1 != $key2 || $val1 != $val2) { + while ((list($key1, $val1) = each($array1)) && (list($key2, $val2) = each($array2))) { + if ($key1 != $key2 || $val1 != $val2) { return false; } } return true; } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Comparers/HttpMethodComparer.php b/src/Mocks/MockHttpService/Comparers/HttpMethodComparer.php index eeef16f8..11fe6ca0 100644 --- a/src/Mocks/MockHttpService/Comparers/HttpMethodComparer.php +++ b/src/Mocks/MockHttpService/Comparers/HttpMethodComparer.php @@ -20,4 +20,4 @@ public function Compare($expected, $actual) return $result; } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Comparers/HttpPathComparer.php b/src/Mocks/MockHttpService/Comparers/HttpPathComparer.php index e582ab9f..9cb05139 100644 --- a/src/Mocks/MockHttpService/Comparers/HttpPathComparer.php +++ b/src/Mocks/MockHttpService/Comparers/HttpPathComparer.php @@ -21,4 +21,4 @@ public function Compare($expected, $actual) return $result; } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Comparers/HttpQueryStringComparer.php b/src/Mocks/MockHttpService/Comparers/HttpQueryStringComparer.php index 1b8de230..564226f7 100644 --- a/src/Mocks/MockHttpService/Comparers/HttpQueryStringComparer.php +++ b/src/Mocks/MockHttpService/Comparers/HttpQueryStringComparer.php @@ -67,18 +67,17 @@ private function ConvertQueryToArray($query) } $equalCount = substr_count($query, "="); - $ampCount = substr_count($query,"&"); + $ampCount = substr_count($query, "&"); if ($equalCount > $ampCount) { $newQuery = ""; $expectAmp = false; - for( $i = 0; $i < strlen($query); $i++ ) { + for ($i = 0; $i < strlen($query); $i++) { if ($query[$i] == "&") { $expectAmp = false; $newQuery .= $query[$i]; - } - else if ($query[$i] == "=") { + } elseif ($query[$i] == "=") { if (!$expectAmp) { $expectAmp = true; $newQuery .= $query[$i]; @@ -126,7 +125,7 @@ private function CompareArray($expected, $actual) } */ - foreach($expectedKeys as $expectedKey=>$expectedArr) { + foreach ($expectedKeys as $expectedKey=>$expectedArr) { // if a key does not exist in expected and not actual, blow up if (!isset($actualKeys[$expectedKey])) { @@ -142,7 +141,7 @@ private function CompareArray($expected, $actual) // walk through each key subarray, if the values do not match, blow up $count = count($expectedArr); - for($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; $i++) { if ($expectedArr[$i] != $actualArr[$i]) { return false; } @@ -180,7 +179,7 @@ private function ExplodeKeys($arr) { $keys = array(); - foreach($arr as $pair) { + foreach ($arr as $pair) { $subpair = explode("=", trim($pair), 2); if (!isset($keys[$subpair[0]])) { $keys[$subpair[0]] = array(); @@ -190,5 +189,4 @@ private function ExplodeKeys($arr) return $keys; } - -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Comparers/HttpStatusCodeComparer.php b/src/Mocks/MockHttpService/Comparers/HttpStatusCodeComparer.php index 8f0e6d00..6513c1eb 100644 --- a/src/Mocks/MockHttpService/Comparers/HttpStatusCodeComparer.php +++ b/src/Mocks/MockHttpService/Comparers/HttpStatusCodeComparer.php @@ -19,4 +19,4 @@ public function Compare($expected, $actual) return $result; } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Comparers/ProviderServiceRequestComparer.php b/src/Mocks/MockHttpService/Comparers/ProviderServiceRequestComparer.php index 33713bbd..18f5cb5e 100644 --- a/src/Mocks/MockHttpService/Comparers/ProviderServiceRequestComparer.php +++ b/src/Mocks/MockHttpService/Comparers/ProviderServiceRequestComparer.php @@ -1,8 +1,8 @@ AddChildResult($queryResult); - if (count($expected->getHeaders()) > 0 ) - { + if (count($expected->getHeaders()) > 0) { $headerResult = $this->_httpHeaderComparer->Compare($expected->getHeaders(), $actual->getHeaders()); $result->AddChildResult($headerResult); } // handles case where body is set but null - if ($expected->ShouldSerializeBody()) - { + if ($expected->ShouldSerializeBody()) { $bodyResult = $this->_httpBodyComparer->Compare($expected, $actual, $expected->getMatchingRules()); $result->AddChildResult($bodyResult); } return $result; } - -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Comparers/ProviderServiceResponseComparer.php b/src/Mocks/MockHttpService/Comparers/ProviderServiceResponseComparer.php index e8bb40dc..f726b960 100644 --- a/src/Mocks/MockHttpService/Comparers/ProviderServiceResponseComparer.php +++ b/src/Mocks/MockHttpService/Comparers/ProviderServiceResponseComparer.php @@ -4,7 +4,6 @@ class ProviderServiceResponseComparer { - private $_httpStatusCodeComparer; //IHttpStatusCodeComparer private $_httpHeaderComparer; //IHttpHeaderComparer private $_httpBodyComparer; //IHttpBodyComparer @@ -34,19 +33,17 @@ public function Compare($expected, $actual) $statusResult = $this->_httpStatusCodeComparer->Compare($expected->getStatus(), $actual->getStatus()); $result->AddChildResult($statusResult); - if (count($expected->getHeaders()) > 0 ) - { + if (count($expected->getHeaders()) > 0) { $headerResult = $this->_httpHeaderComparer->Compare($expected->getHeaders(), $actual->getHeaders()); $result->AddChildResult($headerResult); } // handles case where body is set but null - if ($expected->ShouldSerializeBody()) - { + if ($expected->ShouldSerializeBody()) { $bodyResult = $this->_httpBodyComparer->Compare($expected, $actual, $expected->getMatchingRules()); $result->AddChildResult($bodyResult); } return $result; } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/CustomRequestSender.php b/src/Mocks/MockHttpService/CustomRequestSender.php index d2fb1c7a..2b42802e 100644 --- a/src/Mocks/MockHttpService/CustomRequestSender.php +++ b/src/Mocks/MockHttpService/CustomRequestSender.php @@ -4,10 +4,8 @@ class CustomRequestSender { - public function __construct() { throw new \Exception("Not implemented"); } - -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/HttpClientRequestSender.php b/src/Mocks/MockHttpService/HttpClientRequestSender.php index 6e2b1ebf..30a83610 100644 --- a/src/Mocks/MockHttpService/HttpClientRequestSender.php +++ b/src/Mocks/MockHttpService/HttpClientRequestSender.php @@ -45,5 +45,4 @@ public function Send($request, $baseUri) return $response; } - -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/IHttpHost.php b/src/Mocks/MockHttpService/IHttpHost.php index 89e21447..c91782f2 100644 --- a/src/Mocks/MockHttpService/IHttpHost.php +++ b/src/Mocks/MockHttpService/IHttpHost.php @@ -1,11 +1,10 @@ HttpRequestConvert($request); } @@ -57,8 +57,7 @@ private function checkExistence($obj, $attr) private function GetContentType($request) { $contentTypeStr = "Content-Type"; - if (isset($request->headers) && isset($request->headers->$contentTypeStr)) - { + if (isset($request->headers) && isset($request->headers->$contentTypeStr)) { return $request->headers->$contentTypeStr; } @@ -87,7 +86,6 @@ private function HttpRequestConvert(\Psr\Http\Message\RequestInterface $request) */ $obj->headers = new \stdClass(); if (count($headerArray) > 0) { - foreach ($headerArray as $header_key => $header_value) { if (!is_array($header_value)) { throw new \Exception("This was an unexpected case based on the Windwalker implementation. Make a unit test and pull request."); @@ -113,6 +111,4 @@ private function HttpRequestConvert(\Psr\Http\Message\RequestInterface $request) return $obj; } - - -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Mappers/ProviderServiceResponseMapper.php b/src/Mocks/MockHttpService/Mappers/ProviderServiceResponseMapper.php index 6b9e2d9b..a5bb4e10 100644 --- a/src/Mocks/MockHttpService/Mappers/ProviderServiceResponseMapper.php +++ b/src/Mocks/MockHttpService/Mappers/ProviderServiceResponseMapper.php @@ -12,9 +12,9 @@ public function Convert($response) { if (is_string($response)) { $response = \json_decode($response); - } else if ($response instanceof \Psr\Http\Message\ResponseInterface) { + } elseif ($response instanceof \Psr\Http\Message\ResponseInterface) { $response = $this->HttpResponseConvert($response); - } else if ($response instanceof \PhpPact\Mocks\MockHttpService\Models\ProviderServiceResponse) { + } elseif ($response instanceof \PhpPact\Mocks\MockHttpService\Models\ProviderServiceResponse) { return $response; } @@ -56,7 +56,6 @@ private function HttpResponseConvert(\Psr\Http\Message\ResponseInterface $respon */ $obj->headers = new \stdClass(); if (count($headerArray) > 0) { - foreach ($headerArray as $header_key => $header_value) { if (!is_array($header_value)) { throw new \Exception("This was an unexpected case based on the Windwalker implementation. Make a unit test and pull request."); @@ -88,11 +87,10 @@ private function HttpResponseConvert(\Psr\Http\Message\ResponseInterface $respon private function GetContentType($response) { $contentTypeStr = "Content-Type"; - if (isset($response->headers) && isset($response->headers->$contentTypeStr)) - { + if (isset($response->headers) && isset($response->headers->$contentTypeStr)) { return $response->headers->$contentTypeStr; } return false; } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Matchers/JsonHttpBodyMatcher.php b/src/Mocks/MockHttpService/Matchers/JsonHttpBodyMatcher.php index 0d427464..66225cce 100644 --- a/src/Mocks/MockHttpService/Matchers/JsonHttpBodyMatcher.php +++ b/src/Mocks/MockHttpService/Matchers/JsonHttpBodyMatcher.php @@ -6,7 +6,7 @@ class JsonHttpBodyMatcher implements \PhpPact\Matchers\IMatcher { - CONST PATH = "$..*"; + const PATH = "$..*"; private $_allowExtraKeys; @@ -40,7 +40,8 @@ public function Match($path, $expected, $actual) return new \PhpPact\Matchers\MatcherResult(new \PhpPact\Matchers\FailedMatcherCheck($path, \PhpPact\Matchers\MatcherCheckFailureType::ValueDoesNotMatch)); } - $treewalker = new \TreeWalker(array( + $treewalker = new \TreeWalker( + array( "debug" => false, //true => return the execution time, false => not "returntype" => "array") //Returntype = ["obj","jsonstring","array"] ); @@ -50,7 +51,7 @@ public function Match($path, $expected, $actual) * * Objects can have extra nodes but not arrays. Here, we find all sub arrays and ensure they are the same */ - if ( method_exists($expected, "getBody") && + if (method_exists($expected, "getBody") && method_exists($actual, "getBody") && $this->_allowExtraKeys == true ) { @@ -64,7 +65,7 @@ public function Match($path, $expected, $actual) return new \PhpPact\Matchers\MatcherResult(new \PhpPact\Matchers\FailedMatcherCheck($path, \PhpPact\Matchers\MatcherCheckFailureType::AdditionalPropertyInObject)); } - for($i = 0; $igetdiff($testExpected, $testActual, false); @@ -88,9 +89,9 @@ private function ProcessResults($results, $path, $allowExtraObjectKeys = false) { if (count($results['new']) > 0) { return new \PhpPact\Matchers\MatcherResult(new \PhpPact\Matchers\FailedMatcherCheck($path, \PhpPact\Matchers\MatcherCheckFailureType::AdditionalPropertyInObject)); - } else if (count($results['edited']) > 0) { + } elseif (count($results['edited']) > 0) { return new \PhpPact\Matchers\MatcherResult(new \PhpPact\Matchers\FailedMatcherCheck($path, \PhpPact\Matchers\MatcherCheckFailureType::ValueDoesNotMatch)); - } else if (count($results['removed']) > 0 && $allowExtraObjectKeys == false) { + } elseif (count($results['removed']) > 0 && $allowExtraObjectKeys == false) { return new \PhpPact\Matchers\MatcherResult(new \PhpPact\Matchers\FailedMatcherCheck($path, \PhpPact\Matchers\MatcherCheckFailureType::AdditionalPropertyInObject)); } @@ -103,8 +104,8 @@ private function FindArrays($obj, &$result) foreach ($obj as $key => $value) { $this->FindArrays($value, $result); } - } else if (is_array($obj)) { + } elseif (is_array($obj)) { $result[] = $obj; } } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Matchers/SerializeHttpBodyMatcher.php b/src/Mocks/MockHttpService/Matchers/SerializeHttpBodyMatcher.php index ef671b9a..a22e1b5f 100644 --- a/src/Mocks/MockHttpService/Matchers/SerializeHttpBodyMatcher.php +++ b/src/Mocks/MockHttpService/Matchers/SerializeHttpBodyMatcher.php @@ -8,7 +8,6 @@ namespace PhpPact\Mocks\MockHttpService\Matchers; - class SerializeHttpBodyMatcher implements \PhpPact\Matchers\IMatcher { /** @@ -26,5 +25,4 @@ public function Match($path, $expected, $actual) return new \PhpPact\Matchers\MatcherResult(new \PhpPact\Matchers\FailedMatcherCheck($path, \PhpPact\Matchers\MatcherCheckFailureType::ValueDoesNotMatch)); } - -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/MockProviderHost.php b/src/Mocks/MockHttpService/MockProviderHost.php index 95f54020..32349976 100644 --- a/src/Mocks/MockHttpService/MockProviderHost.php +++ b/src/Mocks/MockHttpService/MockProviderHost.php @@ -107,7 +107,7 @@ public function handle(\Psr\Http\Message\RequestInterface $request) * * @return $this */ - public function return ($result) + public function return($result) { $this->_host = $this->_host->return($result); return $this; @@ -139,20 +139,18 @@ public function ClearRequestResponse() $this->_requestAndResponsePairs = array(); } - private function PrintRequest(\Psr\Http\Message\RequestInterface $request) { - + private function PrintRequest(\Psr\Http\Message\RequestInterface $request) + { $msg = "\nA " . $request->getMethod() . " request with URL: " . $request->getUri()->getHost() . "\n"; $msg .= "\thas path: " . $request->getUri()->getPath() . "\n"; $msg .= "\thas port: " . $request->getUri()->getPort() . "\n"; $msg .= "\thas query: " . $request->getUri()->getQuery() . "\n"; - if (count($request->getHeaders()) > 0 ) - { + if (count($request->getHeaders()) > 0) { $msg .= "\thas headers: \n"; $headers = $request->getHeaders(); - foreach($headers as $key => $value) - { + foreach ($headers as $key => $value) { $msg .= "\t\t" . $key . " with value " . $value[0] . "\n"; } } @@ -165,4 +163,4 @@ private function PrintRequest(\Psr\Http\Message\RequestInterface $request) { return $msg; } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/MockProviderService.php b/src/Mocks/MockHttpService/MockProviderService.php index a8a170c6..b4ed99f7 100644 --- a/src/Mocks/MockHttpService/MockProviderService.php +++ b/src/Mocks/MockHttpService/MockProviderService.php @@ -2,7 +2,6 @@ namespace PhpPact\Mocks\MockHttpService; - class MockProviderService implements IMockProviderService { private $_providerState; @@ -210,7 +209,6 @@ public function VerifyInteractions() // cycle through all the requests we sent foreach ($this->_host->getRequestAndResponsePairs() as $pair) { - if (!isset($pair[\PhpPact\Mocks\MockHttpService\MockProviderHost::REQUEST_KEY])) { throw new \RuntimeException("Request was not set: " . print_r($pair, true)); } @@ -426,5 +424,4 @@ private function IsContentTypeSpecifiedForBody(\PhpPact\Mocks\MockHttpService\Mo return $headers != null && isset($headers["Content-Type"]); } - } diff --git a/src/Mocks/MockHttpService/Models/HandledRequest.php b/src/Mocks/MockHttpService/Models/HandledRequest.php index 54dead8f..f4a6e7d2 100644 --- a/src/Mocks/MockHttpService/Models/HandledRequest.php +++ b/src/Mocks/MockHttpService/Models/HandledRequest.php @@ -4,7 +4,6 @@ class HandledRequest { - public $_actualRequest; public $_matchedInteraction; @@ -29,5 +28,4 @@ public function getMatchedInteraction() { return $this->_matchedInteraction; } - -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Models/HttpVerb.php b/src/Mocks/MockHttpService/Models/HttpVerb.php index 1dd45712..ee8d4a9a 100644 --- a/src/Mocks/MockHttpService/Models/HttpVerb.php +++ b/src/Mocks/MockHttpService/Models/HttpVerb.php @@ -4,7 +4,6 @@ class HttpVerb { - const NOTSET = 0; // only one who had a number in C# const GET = "GET"; const POST = "POST"; @@ -15,7 +14,8 @@ class HttpVerb private $methodTypes; - public function __construct() { + public function __construct() + { $this->methodTypes = array(); $this->methodTypes["NOTSET"] = self::NOTSET; $this->methodTypes["GET"] = self::GET; @@ -26,13 +26,13 @@ public function __construct() { $this->methodTypes["PATCH"] = self::PATCH; } - function Enum($method) { + public function Enum($method) + { $method = strtoupper($method); - if (isset($this->methodTypes[$method])) - { + if (isset($this->methodTypes[$method])) { return $this->methodTypes[$method]; } return self::NOTSET; } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Models/IHttpMessage.php b/src/Mocks/MockHttpService/Models/IHttpMessage.php index fd186a74..3f8c351b 100644 --- a/src/Mocks/MockHttpService/Models/IHttpMessage.php +++ b/src/Mocks/MockHttpService/Models/IHttpMessage.php @@ -34,4 +34,4 @@ public function setHeaders($headers); * @return mixed|bool */ public function getContentType(); -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Models/ProviderServiceInteraction.php b/src/Mocks/MockHttpService/Models/ProviderServiceInteraction.php index 8e3aaf0b..90b8b0ac 100644 --- a/src/Mocks/MockHttpService/Models/ProviderServiceInteraction.php +++ b/src/Mocks/MockHttpService/Models/ProviderServiceInteraction.php @@ -31,7 +31,6 @@ public function __construct() } $this->_providerServiceRequestMapper = new \PhpPact\Mocks\MockHttpService\Mappers\ProviderServiceRequestMapper(); $this->_providerServiceResponseMapper = new \PhpPact\Mocks\MockHttpService\Mappers\ProviderServiceResponseMapper(); - } public function jsonSerialize() @@ -70,4 +69,4 @@ public function setResponse($obj) $this->_response = $this->_providerServiceResponseMapper->Convert($obj); return $this->_response; } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Models/ProviderServicePactFile.php b/src/Mocks/MockHttpService/Models/ProviderServicePactFile.php index c98196cb..fa0fdff9 100644 --- a/src/Mocks/MockHttpService/Models/ProviderServicePactFile.php +++ b/src/Mocks/MockHttpService/Models/ProviderServicePactFile.php @@ -38,7 +38,6 @@ public function setInteractions($interactionArray) } foreach ($interactionArray as $interactionObj) { - if (!isset($interactionObj->description)) { throw new \RuntimeException("description is not set"); } @@ -89,7 +88,7 @@ public function FilterInteractionsByDescription($description) $filteredInteractions = array(); if (count($this->_interactions) > 0) { - foreach($this->_interactions as $interaction) { + foreach ($this->_interactions as $interaction) { if (strtolower($description) == strtolower($interaction->getDescription())) { $filteredInteractions[] = $interaction; } @@ -111,7 +110,7 @@ public function FilterInteractionsByProviderState($state) $filteredInteractions = array(); if (count($this->_interactions) > 0) { - foreach($this->_interactions as $interaction) { + foreach ($this->_interactions as $interaction) { if (strtolower($state) == strtolower($interaction->getProviderState())) { $filteredInteractions[] = $interaction; } @@ -133,7 +132,7 @@ public function FindInteractionsByProviderServiceResponse(\PhpPact\Mocks\MockHtt { $responseComparer = new \PhpPact\Mocks\MockHttpService\Comparers\ProviderServiceResponseComparer(); - foreach($this->_interactions as $interaction) { + foreach ($this->_interactions as $interaction) { /** * @var $interaction \PhpPact\Mocks\MockHttpService\Models\ProviderServiceInteraction */ @@ -159,7 +158,7 @@ public function FindInteractionByProviderServiceRequest(\PhpPact\Mocks\MockHttpS { $requestComparer = new \PhpPact\Mocks\MockHttpService\Comparers\ProviderServiceRequestComparer(); - foreach($this->_interactions as $interaction) { + foreach ($this->_interactions as $interaction) { /** * @var $interaction \PhpPact\Mocks\MockHttpService\Models\ProviderServiceInteraction */ @@ -180,4 +179,4 @@ public function FindInteractionByProviderServiceRequest(\PhpPact\Mocks\MockHttpS throw new \PhpPact\PactFailureException("No interaction found matching this request"); } -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Models/ProviderServiceRequest.php b/src/Mocks/MockHttpService/Models/ProviderServiceRequest.php index 87dc88a8..30183d95 100644 --- a/src/Mocks/MockHttpService/Models/ProviderServiceRequest.php +++ b/src/Mocks/MockHttpService/Models/ProviderServiceRequest.php @@ -4,7 +4,6 @@ class ProviderServiceRequest implements \JsonSerializable, \PhpPact\Mocks\MockHttpService\Models\IHttpMessage { - private $_bodyWasSet; private $_body; private $_method; // use setMethod @@ -34,8 +33,7 @@ public function __construct($method, $path, $headers = null, $body = false) */ public function getBody() { - if ($this->_bodyWasSet) - { + if ($this->_bodyWasSet) { return $this->_body; } @@ -140,15 +138,13 @@ public function PathWithQuery() private function ParseBodyMatchingRules($body) { - $this->_matchingRules = array(); if ($this->getContentType() == "application/json") { $this->_matchingRules[] = new \PhpPact\Mocks\MockHttpService\Matchers\JsonHttpBodyMatcher(false); - } else if ($this->getContentType() == "text/plain") { + } elseif ($this->getContentType() == "text/plain") { $this->_matchingRules[] = new \PhpPact\Mocks\MockHttpService\Matchers\SerializeHttpBodyMatcher(); - } - else { + } else { // make JSON the default based on specification tests $this->_matchingRules[] = new \PhpPact\Mocks\MockHttpService\Matchers\JsonHttpBodyMatcher(false); } @@ -174,7 +170,7 @@ public function getContentType() } - function jsonSerialize() + public function jsonSerialize() { // this _should_ cascade to child classes $obj = new \stdClass(); @@ -185,7 +181,7 @@ function jsonSerialize() $obj->query = $this->_query; } - if ($this->_headers){ + if ($this->_headers) { $header = $this->_headers; if (is_array($header)) { $header = (object)$header; @@ -217,5 +213,4 @@ private function isJsonString($obj) return true; } - -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Models/ProviderServiceResponse.php b/src/Mocks/MockHttpService/Models/ProviderServiceResponse.php index 2f60d717..c36670c4 100644 --- a/src/Mocks/MockHttpService/Models/ProviderServiceResponse.php +++ b/src/Mocks/MockHttpService/Models/ProviderServiceResponse.php @@ -4,7 +4,6 @@ class ProviderServiceResponse implements \JsonSerializable, \PhpPact\Mocks\MockHttpService\Models\IHttpMessage { - private $_bodyWasSet; private $_body; private $_headers; //[JsonProperty(PropertyName = "headers")] / [JsonConverter(typeof(PreserveCasingDictionaryConverter))] @@ -104,10 +103,9 @@ private function ParseBodyMatchingRules($body) if ($this->getContentType() == "application/json") { $this->_matchingRules[] = new \PhpPact\Mocks\MockHttpService\Matchers\JsonHttpBodyMatcher(true); - } else if ($this->getContentType() == "text/plain") { + } elseif ($this->getContentType() == "text/plain") { $this->_matchingRules[] = new \PhpPact\Mocks\MockHttpService\Matchers\SerializeHttpBodyMatcher(); - } - else { + } else { // make JSON the default based on specification tests $this->_matchingRules[] = new \PhpPact\Mocks\MockHttpService\Matchers\JsonHttpBodyMatcher(true); } @@ -133,7 +131,7 @@ public function getContentType() } - function jsonSerialize() + public function jsonSerialize() { // this _should_ cascade to child classes $obj = new \stdClass(); @@ -149,7 +147,8 @@ function jsonSerialize() $obj->body = $this->_body; if ($this->isJsonString($obj->body)) { - $obj->body = \json_decode($obj->body);; + $obj->body = \json_decode($obj->body); + ; } } @@ -169,5 +168,4 @@ private function isJsonString($obj) return true; } - -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Validators/PactFileValidator.php b/src/Mocks/MockHttpService/Validators/PactFileValidator.php index ca02cd2c..41f33f1d 100644 --- a/src/Mocks/MockHttpService/Validators/PactFileValidator.php +++ b/src/Mocks/MockHttpService/Validators/PactFileValidator.php @@ -8,7 +8,6 @@ namespace PhpPact\Mocks\MockHttpService\Validators; - /** * Class PactFileValidator * @@ -49,5 +48,4 @@ private function HuntForSchema() $realPath = realpath($relativeDir); return $realPath; } - -} \ No newline at end of file +} diff --git a/src/Mocks/MockHttpService/Validators/ProviderServiceValidator.php b/src/Mocks/MockHttpService/Validators/ProviderServiceValidator.php index 9b325590..afebd1e9 100644 --- a/src/Mocks/MockHttpService/Validators/ProviderServiceValidator.php +++ b/src/Mocks/MockHttpService/Validators/ProviderServiceValidator.php @@ -98,7 +98,6 @@ public function Validate(\PhpPact\Mocks\MockHttpService\Models\ProviderServicePa $this->_reporter->Indent(); $this->_reporter->ReportSummary($interactionComparisonResult); - } finally { $this->InvokeProviderStateTearDownIfApplicable($providerStateItem); $this->InvokeTearDownIfApplicable($providerStates); @@ -209,4 +208,4 @@ private function InvokeProviderStateTearDownIfApplicable($providerState) return false; } -} \ No newline at end of file +} diff --git a/src/Models/Interaction.php b/src/Models/Interaction.php index c4780058..095ada7a 100644 --- a/src/Models/Interaction.php +++ b/src/Models/Interaction.php @@ -16,7 +16,7 @@ class Interaction implements \JsonSerializable */ private $_providerState; - function jsonSerialize() + public function jsonSerialize() { $obj = new \stdClass(); $obj->description = $this->_description; @@ -65,6 +65,4 @@ public function setProviderState($providerState) $this->_providerState = $providerState; return $this; } - - -} \ No newline at end of file +} diff --git a/src/Models/PactDetails.php b/src/Models/PactDetails.php index a822a476..412aeeab 100644 --- a/src/Models/PactDetails.php +++ b/src/Models/PactDetails.php @@ -28,7 +28,7 @@ public function setLogger($logger) $this->_logger = $logger; } - function jsonSerialize() + public function jsonSerialize() { // this _should_ cascade to child classes $obj = new \stdClass(); @@ -72,10 +72,11 @@ public function setConsumer($consumer) public function GeneratePactFileName() { - $fileName = sprintf("%s-%s.json", + $fileName = sprintf( + "%s-%s.json", $this->_consumer != null ? $this->_consumer->Name : "", - $this->_provider != null ? $this->_provider->Name : ""); + $this->_provider != null ? $this->_provider->Name : "" + ); return \PhpPact\Extensions\StringExtensions::ToLowerSnakeCase($fileName); } - -} \ No newline at end of file +} diff --git a/src/Models/PactFile.php b/src/Models/PactFile.php index a967f394..ccb003b3 100644 --- a/src/Models/PactFile.php +++ b/src/Models/PactFile.php @@ -21,14 +21,12 @@ public function jsonSerialize() return $obj; } - function setMetadata($obj) + public function setMetadata($obj) { - if (isset($obj->metadata) && isset($obj->metadata->pactSpecificationVersion)) - { + if (isset($obj->metadata) && isset($obj->metadata->pactSpecificationVersion)) { $this->_metadata = $obj->metadata; return $this->_metadata; - } else if (isset($obj->pactSpecificationVersion)) - { + } elseif (isset($obj->pactSpecificationVersion)) { $this->_metadata = $obj; return $this->_metadata; } @@ -36,7 +34,8 @@ function setMetadata($obj) throw new \RuntimeException("Metadata is not in the appropriate format"); } - function getMetadata() { + public function getMetadata() + { return $this->_metadata; } @@ -49,4 +48,4 @@ public function getFileName() { return strtolower($this->getConsumer()->getName()) . '-' . strtolower($this->getProvider()->getName()) . '.json'; } -} \ No newline at end of file +} diff --git a/src/Models/Pacticipant.php b/src/Models/Pacticipant.php index 9037acda..f04c4e07 100644 --- a/src/Models/Pacticipant.php +++ b/src/Models/Pacticipant.php @@ -13,7 +13,7 @@ public function __construct($name = null) } } - function jsonSerialize() + public function jsonSerialize() { $obj = new \stdClass(); $obj->name = $this->_name; @@ -21,12 +21,12 @@ function jsonSerialize() return $obj; } - function setName($obj) + public function setName($obj) { if (isset($obj->name)) { $this->_name = $obj->name; return $this->_name; - } else if (is_string($obj)) { + } elseif (is_string($obj)) { $this->_name = $obj; return $this->_name; } @@ -34,10 +34,8 @@ function setName($obj) throw new \RuntimeException("Name is not in the appropriate format"); } - function getName() + public function getName() { return $this->_name; } - - -} \ No newline at end of file +} diff --git a/src/Models/ProviderState.php b/src/Models/ProviderState.php index b0268476..2d9f651b 100644 --- a/src/Models/ProviderState.php +++ b/src/Models/ProviderState.php @@ -22,5 +22,4 @@ public function __toString() { return $this->ProviderStateDescription; } - -} \ No newline at end of file +} diff --git a/src/Models/ProviderStates.php b/src/Models/ProviderStates.php index c872f414..eae8cdd6 100644 --- a/src/Models/ProviderStates.php +++ b/src/Models/ProviderStates.php @@ -59,5 +59,4 @@ public function Find($providerState) return null; } - -} \ No newline at end of file +} diff --git a/src/PactBaseConfig.php b/src/PactBaseConfig.php index a319b36c..0c711688 100644 --- a/src/PactBaseConfig.php +++ b/src/PactBaseConfig.php @@ -61,12 +61,12 @@ protected function setDefaultLogConfig() { $defaultLogValue = ini_get('error_log'); - // if there is no log set, send everything to stderr - $consoleLevel = 'info'; - if (!$defaultLogValue) { - $consoleLevel = 'DEBUG'; - } - + // if there is no log set, send everything to stderr + $consoleLevel = 'info'; + if (!$defaultLogValue) { + $consoleLevel = 'DEBUG'; + } + $appenders = array( 'console' => array( 'class' => 'LoggerAppenderConsole', @@ -76,29 +76,28 @@ protected function setDefaultLogConfig() 'threshold' => $consoleLevel )); - // if there is log set, add another appender - if ($defaultLogValue != false && $defaultLogValue != "stderr") { - if ($defaultLogValue != 'syslog') { - $appenders["file"] = array( - 'class' => 'LoggerAppenderFile', - 'layout' => array( - 'class' => 'LoggerLayoutSimple' - ), - 'params' => array( - 'file' => $defaultLogValue), - 'append' => true - ); - } - else { - $appenders['syslog'] = array( - 'class' => 'LoggerAppenderSyslog', - 'layout' => array( - 'class' => 'LoggerLayoutSimple' - ) - ); - } - } - + // if there is log set, add another appender + if ($defaultLogValue != false && $defaultLogValue != "stderr") { + if ($defaultLogValue != 'syslog') { + $appenders["file"] = array( + 'class' => 'LoggerAppenderFile', + 'layout' => array( + 'class' => 'LoggerLayoutSimple' + ), + 'params' => array( + 'file' => $defaultLogValue), + 'append' => true + ); + } else { + $appenders['syslog'] = array( + 'class' => 'LoggerAppenderSyslog', + 'layout' => array( + 'class' => 'LoggerLayoutSimple' + ) + ); + } + } + \Logger::configure(array( 'rootLogger' => array( 'appenders' => array_keys($appenders), @@ -138,14 +137,13 @@ public function setBaseUri($baseUri, $port = \PhpPact\Constants::DEFAULT_PORT, $ $baseUri = substr($baseUri, 0, strlen($baseUri) - 1); } - if (strtolower(substr($baseUri, 0, 4)) == 'http' ) { - if (strtolower(substr($baseUri, 0, 5)) == 'https' ){ + if (strtolower(substr($baseUri, 0, 4)) == 'http') { + if (strtolower(substr($baseUri, 0, 5)) == 'https') { // strip off protocol // account for :// $protocol = 'https'; $baseUri = substr($baseUri, 8, strlen($baseUri) - 8); - } - else { + } else { // strip off protocol // account for :// $protocol = 'http'; @@ -201,6 +199,4 @@ public function getBaseUrn() } return $this->_baseUrn; } - - -} \ No newline at end of file +} diff --git a/src/PactBrokerConnector.php b/src/PactBrokerConnector.php index c96d87cb..67e0a49b 100644 --- a/src/PactBrokerConnector.php +++ b/src/PactBrokerConnector.php @@ -119,7 +119,6 @@ public function Publish(\PhpPact\Mocks\MockHttpService\Models\ProviderServicePac } return false; - } @@ -182,7 +181,6 @@ public function RetrieveLatestProviderPacts($providerName) */ public function RetrievePact($providerName, $consumerName, $version = "latest") { - $url = $this->_uriOptions->getBaseUri(); $path = '/pacts/provider/' . urlencode($providerName) . '/consumer/' . urlencode($consumerName); @@ -228,4 +226,4 @@ private function ExtractVersionFromUrl($url) $index = count($arr) - 1; return $arr[$index]; } -} \ No newline at end of file +} diff --git a/src/PactBuilder.php b/src/PactBuilder.php index 309683f6..5bc1ac71 100644 --- a/src/PactBuilder.php +++ b/src/PactBuilder.php @@ -97,7 +97,7 @@ public function setConfig(PactConfig $config) * @param $providerName * @param PactConfig $config */ - public function setMockService($providerName, \PhpPact\PactConfig $config ) + public function setMockService($providerName, \PhpPact\PactConfig $config) { $this->_mockProviderService = new \PhpPact\Mocks\MockHttpService\MockProviderService($providerName, $config); @@ -109,8 +109,7 @@ public function setMockService($providerName, \PhpPact\PactConfig $config ) */ public function getMockService() { - if (!$this->_mockProviderService) - { + if (!$this->_mockProviderService) { throw new \RuntimeException("Mock provider service has not been initialized"); } @@ -121,7 +120,7 @@ public function getMockService() * @param string $consumerName * @return $this */ - function ServiceConsumer($consumerName) + public function ServiceConsumer($consumerName) { if (!$consumerName) { throw new \RuntimeException("Please supply a non null or empty consumerName"); @@ -137,7 +136,7 @@ function ServiceConsumer($consumerName) * @param string $providerName * @return $this */ - function HasPactWith($providerName) + public function HasPactWith($providerName) { if (!$providerName) { throw new \RuntimeException("Please supply a non null or empty providerName"); @@ -199,4 +198,4 @@ private function PersistPactFile(\PhpPact\Models\PactFile $pactFile) $fileName = $this->_config->getPactDir() . '/' . $pactFile->getFileName(); file_put_contents($fileName, $output); } -} \ No newline at end of file +} diff --git a/src/PactConfig.php b/src/PactConfig.php index 48bc9920..cbda8557 100644 --- a/src/PactConfig.php +++ b/src/PactConfig.php @@ -29,5 +29,4 @@ public function setPactDir(string $pactDir) $this->_pactDir = $pactDir; return $this; } - -} \ No newline at end of file +} diff --git a/src/PactFailureException.php b/src/PactFailureException.php index 63da9dd3..d85eac0a 100644 --- a/src/PactFailureException.php +++ b/src/PactFailureException.php @@ -3,10 +3,10 @@ class PactFailureException extends \Exception { - public function __construct ($message = "", $code = 0 , $previous = NULL ) + public function __construct($message = "", $code = 0, $previous = null) { if (is_callable('parent::__construct')) { parent::__construct($message, $code, $previous); } } -} \ No newline at end of file +} diff --git a/src/PactUriOptions.php b/src/PactUriOptions.php index 7a9984ce..92d81cae 100644 --- a/src/PactUriOptions.php +++ b/src/PactUriOptions.php @@ -18,7 +18,6 @@ class PactUriOptions */ public function __construct($uri, $username = null, $password = null) { - if (!$uri) { throw new \InvalidArgumentException("uri is null or empty."); } @@ -104,4 +103,4 @@ public function AuthorizationHeader() } return self::AuthScheme . ' ' . base64_encode(utf8_encode(sprintf("%s:%s", $this->_username, $this->_password))); } -} \ No newline at end of file +} diff --git a/src/PactVerifier.php b/src/PactVerifier.php index 3f90516a..cc5409f3 100644 --- a/src/PactVerifier.php +++ b/src/PactVerifier.php @@ -16,7 +16,7 @@ class PactVerifier implements IPactVerifier private $_pactFileUri; private $_pactUriOptions; - function __construct($baseUri) + public function __construct($baseUri) { $this->_providerStates = new \PhpPact\Models\ProviderStates(); $this->_httpClient = new \Windwalker\Http\HttpClient(); @@ -66,7 +66,7 @@ public function ProviderState($providerState, $setUp = null, $tearDown = null) return $this; } - function ServiceProvider($providerName, $httpClient = null, $httpRequestSender = null) + public function ServiceProvider($providerName, $httpClient = null, $httpRequestSender = null) { if (!$providerName) { throw new \InvalidArgumentException("Please supply a non null or empty providerName"); @@ -91,7 +91,7 @@ function ServiceProvider($providerName, $httpClient = null, $httpRequestSender = return $this; } - function HonoursPactWith($consumerName) + public function HonoursPactWith($consumerName) { if (!$consumerName) { throw new \InvalidArgumentException("Please supply a non null or empty consumerName"); @@ -122,7 +122,7 @@ public function PactUri($uri, $options = null) return $this; } - function Verify($description = null, $providerState = null) + public function Verify($description = null, $providerState = null) { if (!$this->_httpRequestSender) { throw new \InvalidArgumentException("httpRequestSender has not been set, please supply a httpClient or httpRequestSenderFunc using the ServiceProvider method."); @@ -165,4 +165,4 @@ function Verify($description = null, $providerState = null) throw $e; } } -} \ No newline at end of file +} diff --git a/src/PactVerifierConfig.php b/src/PactVerifierConfig.php index d5a43cb1..8b78296f 100644 --- a/src/PactVerifierConfig.php +++ b/src/PactVerifierConfig.php @@ -32,5 +32,4 @@ public function setReportOutputters(array $reportOutputters) { $this->_reportOutputters = $reportOutputters; } - -} \ No newline at end of file +} diff --git a/src/Reporters/IReporter.php b/src/Reporters/IReporter.php index d3e65e8b..2b452039 100644 --- a/src/Reporters/IReporter.php +++ b/src/Reporters/IReporter.php @@ -1,6 +1,7 @@ _logger->$writeLevel($report); } -} \ No newline at end of file +} diff --git a/src/Reporters/Reporter.php b/src/Reporters/Reporter.php index 95bc2afe..b2398cde 100644 --- a/src/Reporters/Reporter.php +++ b/src/Reporters/Reporter.php @@ -18,16 +18,11 @@ public function __construct($config, $outputters = array()) { if (count($outputters) > 0) { $this->_outputters = $outputters; - } - else if ($config instanceof \PhpPact\PactVerifierConfig) - { + } elseif ($config instanceof \PhpPact\PactVerifierConfig) { $this->_outputters = $config->getReportOutputters(); - } - else - { + } else { throw new Exception("Invalid parameters. Either provide a valid config or valid outputters"); } - } @@ -77,7 +72,6 @@ private function AddSummary(\PhpPact\Comparers\ComparisonResult $comparisonResul } if ($comparisonResult->HasFailure()) { - $failureBuilder = ''; $shallowFailureCount = $comparisonResult->ShallowFailureCount(); @@ -121,7 +115,6 @@ private function WriteFailureReasons(\PhpPact\Comparers\ComparisonResult $compar $this->AddReportLine("Failures:", 0); foreach ($comparisonResult->Failures() as $failure) { - $this->AddReportLine('', 0); $this->AddReportLine(sprintf("%s %s", $this->_failureCount, $failure->getResult()), 0); } @@ -133,4 +126,4 @@ private function AddReportLine($message, $tabDepth) $indentation = implode('', $a); $this->_reportLines[] = $indentation . $message; } -} \ No newline at end of file +} diff --git a/test/Comparers/ComparisonResultTest.php b/test/Comparers/ComparisonResultTest.php index 066bb8ec..29dd3e50 100644 --- a/test/Comparers/ComparisonResultTest.php +++ b/test/Comparers/ComparisonResultTest.php @@ -104,7 +104,5 @@ public function testFailures() $this->assertEquals(0, $results->ShallowFailureCount(), "Expect shallow failures"); $this->assertEquals(2, count($results->Failures()), "Expect two failures"); $this->assertTrue($results->HasFailure(), "Expect failures"); - } - } diff --git a/test/IntegrationTests/MockHttpServiceSpecificationTests.php b/test/IntegrationTests/MockHttpServiceSpecificationTests.php index a645f9ff..24b8816b 100644 --- a/test/IntegrationTests/MockHttpServiceSpecificationTests.php +++ b/test/IntegrationTests/MockHttpServiceSpecificationTests.php @@ -10,7 +10,6 @@ use PHPUnit\Framework\TestCase; - class MockHttpServiceSpecificationTests extends TestCase { @@ -48,22 +47,20 @@ private function RunPactSpecificationTests($pathToTestCases, $testCaseType) $hasException = false; try { - switch ($testCaseType) { - case 'request' : + case 'request': $testCaseRunner = new Models\RequestTestCase(); $testCaseRunner->Initialize($testCaseJson); break; - case 'response' : + case 'response': $testCaseRunner = new Models\ResponseTestCase(); $testCaseRunner->Initialize($testCaseJson); break; - default : + default: throw new \InvalidArgumentException("Unexpected test case runner type: " . $testCaseType); } $testCaseRunner->Verify(); - } catch (\Exception $e) { $hasException = true; } diff --git a/test/IntegrationTests/Models/RequestTestCase.php b/test/IntegrationTests/Models/RequestTestCase.php index 85ffc777..747f26c3 100644 --- a/test/IntegrationTests/Models/RequestTestCase.php +++ b/test/IntegrationTests/Models/RequestTestCase.php @@ -13,10 +13,8 @@ use \PhpPact\Mocks\MockHttpService\Models\ProviderServiceRequest; use \PhpPact\Mocks\MockHttpService\Mappers\ProviderServiceRequestMapper; - class RequestTestCase extends TestCase { - private $_match; private $_comment; @@ -39,7 +37,8 @@ class RequestTestCase extends TestCase * Using this function to avoid overriding PHPUnitTestCase constructors * @param $json */ - public function Initialize($json) { + public function Initialize($json) + { $this->_requestComparer = new ProviderServiceRequestComparer(); $jsonObj = \json_decode($json); @@ -146,4 +145,4 @@ public function Verify() $this->assertEquals(1, count($result->Failures())); } } -} \ No newline at end of file +} diff --git a/test/IntegrationTests/Models/ResponseTestCase.php b/test/IntegrationTests/Models/ResponseTestCase.php index 0b471483..4c7babab 100644 --- a/test/IntegrationTests/Models/ResponseTestCase.php +++ b/test/IntegrationTests/Models/ResponseTestCase.php @@ -13,10 +13,8 @@ use \PhpPact\Mocks\MockHttpService\Models\ProviderServiceResponse; use \PhpPact\Mocks\MockHttpService\Mappers\ProviderServiceResponseMapper; - class ResponseTestCase extends TestCase { - private $_match; private $_comment; @@ -39,7 +37,8 @@ class ResponseTestCase extends TestCase * Using this function to avoid overriding PHPUnitTestCase constructors * @param $json */ - public function Initialize($json) { + public function Initialize($json) + { $this->_responseComparer = new ProviderServiceResponseComparer(); $jsonObj = \json_decode($json); @@ -137,4 +136,4 @@ public function Verify() $this->assertEquals(1, count($result->Failures())); } } -} \ No newline at end of file +} diff --git a/test/Mocks/MockHttpService/Comparers/HttpBodyComparerTest.php b/test/Mocks/MockHttpService/Comparers/HttpBodyComparerTest.php index 23f695c9..f1057b71 100644 --- a/test/Mocks/MockHttpService/Comparers/HttpBodyComparerTest.php +++ b/test/Mocks/MockHttpService/Comparers/HttpBodyComparerTest.php @@ -67,5 +67,4 @@ public function testCompare() $this->assertTrue($hasException, "Expect a failure to happen"); */ } - } diff --git a/test/Mocks/MockHttpService/Comparers/HttpHeaderComparerTest.php b/test/Mocks/MockHttpService/Comparers/HttpHeaderComparerTest.php index 6ca7d859..98082a4b 100644 --- a/test/Mocks/MockHttpService/Comparers/HttpHeaderComparerTest.php +++ b/test/Mocks/MockHttpService/Comparers/HttpHeaderComparerTest.php @@ -13,8 +13,8 @@ class HttpHeaderComparerTest extends TestCase { - public function testCompare() { - + public function testCompare() + { $comparer = new HttpHeaderComparer(); // test that expected is a subset of actual diff --git a/test/Mocks/MockHttpService/Comparers/HttpQueryStringComparerTest.php b/test/Mocks/MockHttpService/Comparers/HttpQueryStringComparerTest.php index 37136875..5543d542 100644 --- a/test/Mocks/MockHttpService/Comparers/HttpQueryStringComparerTest.php +++ b/test/Mocks/MockHttpService/Comparers/HttpQueryStringComparerTest.php @@ -12,7 +12,8 @@ class HttpQueryStringComparerTest extends TestCase { - public function testCompare() { + public function testCompare() + { $comparer = new \PhpPact\Mocks\MockHttpService\Comparers\HttpQueryStringComparer(); $expectedUrl = "http://localhost/"; @@ -50,5 +51,4 @@ public function testCompare() { $results = $comparer->Compare($expectedUrl, $actualUrl); $this->assertFalse($results->HasFailure(), "We expect no failures as the extra = should be encoded during the test"); } - } diff --git a/test/Mocks/MockHttpService/Comparers/HttpStatusCodeComparerTest.php b/test/Mocks/MockHttpService/Comparers/HttpStatusCodeComparerTest.php index 65a07b81..af1d89fb 100644 --- a/test/Mocks/MockHttpService/Comparers/HttpStatusCodeComparerTest.php +++ b/test/Mocks/MockHttpService/Comparers/HttpStatusCodeComparerTest.php @@ -13,7 +13,8 @@ class HttpStatusCodeComparerTest extends TestCase { - public function testCompare() { + public function testCompare() + { $comparer = new HttpStatusCodeComparer(); $expected = 200; @@ -23,5 +24,4 @@ public function testCompare() { $result = $comparer->Compare($expected, '300'); $this->assertEquals(1, $result->ShallowFailureCount(), "One failure expected"); } - } diff --git a/test/Mocks/MockHttpService/Comparers/ProviderServiceRequestComparerTest.php b/test/Mocks/MockHttpService/Comparers/ProviderServiceRequestComparerTest.php index 6e6e9de3..69a8e290 100644 --- a/test/Mocks/MockHttpService/Comparers/ProviderServiceRequestComparerTest.php +++ b/test/Mocks/MockHttpService/Comparers/ProviderServiceRequestComparerTest.php @@ -26,7 +26,7 @@ public function testConvert() $request2 = new \PhpPact\Mocks\MockHttpService\Models\ProviderServiceRequest("GET", "/", $header, $body); $results = $comparer->Compare($request1, $request2); - $this->assertFalse($results->HasFailure(), "We expect these two requests to match" ); + $this->assertFalse($results->HasFailure(), "We expect these two requests to match"); // expect headers to be off $header = array(); @@ -43,7 +43,7 @@ public function testConvert() $request2 = new \PhpPact\Mocks\MockHttpService\Models\ProviderServiceRequest("GET", "/", $header2, $body); $results = $comparer->Compare($request1, $request2); - $this->assertTrue($results->HasFailure(), "We expect these two requests to differ by the header. Note that the actual can have more header entries than the expected." ); + $this->assertTrue($results->HasFailure(), "We expect these two requests to differ by the header. Note that the actual can have more header entries than the expected."); // expect path to be off $header = array(); @@ -55,7 +55,7 @@ public function testConvert() $request2 = new \PhpPact\Mocks\MockHttpService\Models\ProviderServiceRequest("GET", "/new", $header, $body); $results = $comparer->Compare($request1, $request2); - $this->assertTrue($results->HasFailure(), "We expect these two requests to differ by path" ); + $this->assertTrue($results->HasFailure(), "We expect these two requests to differ by path"); // expect method to be off $header = array(); @@ -67,7 +67,7 @@ public function testConvert() $request2 = new \PhpPact\Mocks\MockHttpService\Models\ProviderServiceRequest("POST", "/", $header, $body); $results = $comparer->Compare($request1, $request2); - $this->assertTrue($results->HasFailure(), "We expect these two requests to differ by method" ); + $this->assertTrue($results->HasFailure(), "We expect these two requests to differ by method"); // expect body to be off $header = array(); @@ -80,6 +80,6 @@ public function testConvert() $request2 = new \PhpPact\Mocks\MockHttpService\Models\ProviderServiceRequest("GET", "/", $header, $body2); $results = $comparer->Compare($request1, $request2); - $this->assertTrue($results->HasFailure(), "We expect these two requests to differ by body" ); + $this->assertTrue($results->HasFailure(), "We expect these two requests to differ by body"); } } diff --git a/test/Mocks/MockHttpService/Comparers/ProviderServiceResponseComparerTest.php b/test/Mocks/MockHttpService/Comparers/ProviderServiceResponseComparerTest.php index 8a8c782d..114cee6d 100644 --- a/test/Mocks/MockHttpService/Comparers/ProviderServiceResponseComparerTest.php +++ b/test/Mocks/MockHttpService/Comparers/ProviderServiceResponseComparerTest.php @@ -8,13 +8,10 @@ namespace PhpPact\Mocks\MockHttpService\Comparers; - - use PHPUnit\Framework\TestCase; class ProviderServiceResponseComparerTest extends TestCase { - public function testConvert() { $comparer = new \PhpPact\Mocks\MockHttpService\Comparers\ProviderServiceResponseComparer(); @@ -28,7 +25,7 @@ public function testConvert() $response2 = new \PhpPact\Mocks\MockHttpService\Models\ProviderServiceResponse(200, $header, $body); $results = $comparer->Compare($response1, $response2); - $this->assertFalse($results->HasFailure(), "We expect these two responses to match." ); + $this->assertFalse($results->HasFailure(), "We expect these two responses to match."); // expect header failure $header = array(); @@ -45,7 +42,7 @@ public function testConvert() $response2 = new \PhpPact\Mocks\MockHttpService\Models\ProviderServiceResponse(200, $header2, $body); $results = $comparer->Compare($response2, $response1); - $this->assertTrue($results->HasFailure(), "We expect these two responses to not to match as the headers are off." ); + $this->assertTrue($results->HasFailure(), "We expect these two responses to not to match as the headers are off."); // check status $header = array(); @@ -57,7 +54,7 @@ public function testConvert() $response2 = new \PhpPact\Mocks\MockHttpService\Models\ProviderServiceResponse(500, $header, $body); $results = $comparer->Compare($response1, $response2); - $this->assertTrue($results->HasFailure(), "We expect these two responses to not to match as the statuses are off." ); + $this->assertTrue($results->HasFailure(), "We expect these two responses to not to match as the statuses are off."); // check body $header = array(); @@ -70,6 +67,6 @@ public function testConvert() $response2 = new \PhpPact\Mocks\MockHttpService\Models\ProviderServiceResponse(200, $header, $body2); $results = $comparer->Compare($response1, $response2); - $this->assertTrue($results->HasFailure(), "We expect these two responses to not to match as the bodies are different." ); + $this->assertTrue($results->HasFailure(), "We expect these two responses to not to match as the bodies are different."); } } diff --git a/test/Mocks/MockHttpService/Mappers/HttpRequestMessageMapperTest.php b/test/Mocks/MockHttpService/Mappers/HttpRequestMessageMapperTest.php index 7e9bdfc4..166d1a48 100644 --- a/test/Mocks/MockHttpService/Mappers/HttpRequestMessageMapperTest.php +++ b/test/Mocks/MockHttpService/Mappers/HttpRequestMessageMapperTest.php @@ -13,8 +13,8 @@ class HttpRequestMessageMapperTest extends TestCase { - - public function testConvert() { + public function testConvert() + { $mapper = new \PhpPact\Mocks\MockHttpService\Mappers\HttpRequestMessageMapper(); // test standard @@ -33,7 +33,7 @@ public function testConvert() { $actualHeaders = $httpRequest->getHeaders(); $this->assertTrue(isset($actualHeaders["Content-Type"]), "We expect one header - content-type"); - $this->assertEquals('/test',$httpRequest->getUri()->getPath(), "Test that path was set appropriately"); + $this->assertEquals('/test', $httpRequest->getUri()->getPath(), "Test that path was set appropriately"); $this->assertFalse(($httpRequest->getUri()->getQuery()? true : false), "Test that query was not set. Note this is an explicit false check"); $this->assertEquals($obj->body, (string) $httpRequest->getBody(), "Body is set appropriately"); @@ -55,9 +55,8 @@ public function testConvert() { $actualHeaders = $httpRequest->getHeaders(); $this->assertTrue(isset($actualHeaders["Content-Type"]), "We expect one header - content-type"); - $this->assertEquals('/test',$httpRequest->getUri()->getPath(), "Test that path was set appropriately"); + $this->assertEquals('/test', $httpRequest->getUri()->getPath(), "Test that path was set appropriately"); $this->assertEquals("x=1&y=2", $httpRequest->getUri()->getQuery(), "Test that query was set with the ? removed"); $this->assertEquals($obj->body, (string) $httpRequest->getBody(), "Body is set appropriately"); } - } diff --git a/test/Mocks/MockHttpService/Mappers/HttpResponseMessageMapperTest.php b/test/Mocks/MockHttpService/Mappers/HttpResponseMessageMapperTest.php index f77bff20..4e5125c2 100644 --- a/test/Mocks/MockHttpService/Mappers/HttpResponseMessageMapperTest.php +++ b/test/Mocks/MockHttpService/Mappers/HttpResponseMessageMapperTest.php @@ -29,7 +29,7 @@ public function testConvert() $expectedContent = ($response->getHeaders())["Content-Type"]; $actualContent = ($httpResponse->getHeaders())["Content-Type"][0]; - $this->assertEquals($expectedContent,$actualContent, "Ensure the header content is the same"); + $this->assertEquals($expectedContent, $actualContent, "Ensure the header content is the same"); $this->assertEquals(count($response->getHeaders()), count($httpResponse->getHeaders()), "The header count should be the same"); $this->assertEquals($response->getBody(), (string) $httpResponse->getBody(), "Make sure the body is set."); } diff --git a/test/Mocks/MockHttpService/Mappers/ProviderServicePactMapperTest.php b/test/Mocks/MockHttpService/Mappers/ProviderServicePactMapperTest.php index b8ae8d78..3da85410 100644 --- a/test/Mocks/MockHttpService/Mappers/ProviderServicePactMapperTest.php +++ b/test/Mocks/MockHttpService/Mappers/ProviderServicePactMapperTest.php @@ -13,7 +13,8 @@ class ProviderServicePactMapperTest extends TestCase { - public function testConvert() { + public function testConvert() + { // most of this is covered by other unit tests. Basic coverage provided below $mapper = new ProviderServicePactMapper(); @@ -28,12 +29,12 @@ public function testConvert() { $obj->interactions = array(); $providerServicePactFile = $mapper->Convert($obj); - $this->assertEquals('MyProvider', $providerServicePactFile->getProvider()->getName(),"Provider name should be set"); - $this->assertEquals('4.1', $providerServicePactFile->getMetadata()->pactSpecificationVersion,"Specification should be set"); + $this->assertEquals('MyProvider', $providerServicePactFile->getProvider()->getName(), "Provider name should be set"); + $this->assertEquals('4.1', $providerServicePactFile->getMetadata()->pactSpecificationVersion, "Specification should be set"); $json = '{ "provider": { "name": "ProviderApi" }, "consumer": { "name": "ApiConsumer" },"interactions": [], "metadata": { "pactSpecificationVersion": "1.1.0" } }'; $providerServicePactFile = $mapper->Convert($json); - $this->assertEquals('ApiConsumer', $providerServicePactFile->getConsumer()->getName(),"Consumer name should be set"); - $this->assertEquals('1.1.0', $providerServicePactFile->getMetadata()->pactSpecificationVersion,"Specification should be set"); + $this->assertEquals('ApiConsumer', $providerServicePactFile->getConsumer()->getName(), "Consumer name should be set"); + $this->assertEquals('1.1.0', $providerServicePactFile->getMetadata()->pactSpecificationVersion, "Specification should be set"); } } diff --git a/test/Mocks/MockHttpService/Mappers/ProviderServiceRequestMapperTest.php b/test/Mocks/MockHttpService/Mappers/ProviderServiceRequestMapperTest.php index b3b9f0b5..b4786b6f 100644 --- a/test/Mocks/MockHttpService/Mappers/ProviderServiceRequestMapperTest.php +++ b/test/Mocks/MockHttpService/Mappers/ProviderServiceRequestMapperTest.php @@ -13,7 +13,8 @@ class ProviderServiceRequestMapperTest extends TestCase { - public function testConvert() { + public function testConvert() + { $mapper = new ProviderServiceRequestMapper(); $obj = new \stdClass(); @@ -35,7 +36,7 @@ public function testConvert() { $obj->body = "Do not tell me what I can do to my body"; $providerServiceRequest = $mapper->Convert($obj); - $this->assertEquals("Do not tell me what I can do to my body", $providerServiceRequest->getBody(), "Body has been set to a string"); + $this->assertEquals("Do not tell me what I can do to my body", $providerServiceRequest->getBody(), "Body has been set to a string"); $obj = new \stdClass(); $obj->method = 'get'; @@ -44,7 +45,7 @@ public function testConvert() { $obj->body = "Do not tell me what I can do to my body"; $providerServiceRequest = $mapper->Convert($obj); - $this->assertEquals("Do not tell me what I can do to my body", $providerServiceRequest->getBody(), "Body has been set to a string"); + $this->assertEquals("Do not tell me what I can do to my body", $providerServiceRequest->getBody(), "Body has been set to a string"); $obj = new \stdClass(); $obj->method = 'get'; @@ -53,7 +54,7 @@ public function testConvert() { $obj->body = "{ \"typeId\": 1001, \"name\": \"talking\" }"; $providerServiceRequest = $mapper->Convert($obj); - $this->assertEquals($obj->body, $providerServiceRequest->getBody(), "Body has not been converted to json."); + $this->assertEquals($obj->body, $providerServiceRequest->getBody(), "Body has not been converted to json."); $obj = new \stdClass(); $obj->method = 'get'; @@ -62,7 +63,7 @@ public function testConvert() { $obj->body = \json_decode("{ \"typeId\": 1001, \"name\": \"talking\" }"); $providerServiceRequest = $mapper->Convert($obj); - $this->assertEquals($obj->body, $providerServiceRequest->getBody(), "Body is an object, which should be allowed, and not converted to JSON b/c of the header was not set"); + $this->assertEquals($obj->body, $providerServiceRequest->getBody(), "Body is an object, which should be allowed, and not converted to JSON b/c of the header was not set"); $obj = new \stdClass(); $obj->method = 'get'; @@ -75,6 +76,6 @@ public function testConvert() { $obj->body = $json; $providerServiceRequest = $mapper->Convert($obj); - $this->assertEquals($obj->body, $providerServiceRequest->getBody(), "Body is converted to JSON bc of the header"); + $this->assertEquals($obj->body, $providerServiceRequest->getBody(), "Body is converted to JSON bc of the header"); } } diff --git a/test/Mocks/MockHttpService/Mappers/ProviderServiceResponseMapperTest.php b/test/Mocks/MockHttpService/Mappers/ProviderServiceResponseMapperTest.php index 39ab39be..f7d9c491 100644 --- a/test/Mocks/MockHttpService/Mappers/ProviderServiceResponseMapperTest.php +++ b/test/Mocks/MockHttpService/Mappers/ProviderServiceResponseMapperTest.php @@ -42,7 +42,7 @@ public function testConvert() $obj->body = "Do not tell me what I can do to my body"; $providerServiceResponse = $mapper->Convert($obj); - $this->assertEquals("Do not tell me what I can do to my body", $providerServiceResponse->getBody(), "Body has been set to a string"); + $this->assertEquals("Do not tell me what I can do to my body", $providerServiceResponse->getBody(), "Body has been set to a string"); $obj = new \stdClass(); @@ -51,7 +51,7 @@ public function testConvert() $obj->body = "{ \"typeId\": 1001, \"name\": \"talking\" }"; $providerServiceResponse = $mapper->Convert($obj); - $this->assertEquals($obj->body, $providerServiceResponse->getBody(), "Body has not been converted to json."); + $this->assertEquals($obj->body, $providerServiceResponse->getBody(), "Body has not been converted to json."); $obj = new \stdClass(); $obj->status = 200; @@ -59,7 +59,7 @@ public function testConvert() $obj->body = \json_decode("{ \"typeId\": 1001, \"name\": \"talking\" }"); $providerServiceResponse = $mapper->Convert($obj); - $this->assertEquals($obj->body, $providerServiceResponse->getBody(), "Body is an object, which should be allowed."); + $this->assertEquals($obj->body, $providerServiceResponse->getBody(), "Body is an object, which should be allowed."); $json = "{ \"status\": 200, \"headers\": { \"Content-Type\": \"application/json\" }, \"body\": { \"segmentTypes\": [ { \"typeId\": 1000, \"name\": \"Negative Segment\" } ] } }"; @@ -74,5 +74,4 @@ public function testConvert() $this->assertEquals(500, $providerServiceResponse->getStatus(), 'Method was set appropriately'); $this->assertEquals(1, count($providerServiceResponse->getHeaders()), "We expect one header"); } - } diff --git a/test/Mocks/MockHttpService/Matchers/JsonHttpBodyMatcherTest.php b/test/Mocks/MockHttpService/Matchers/JsonHttpBodyMatcherTest.php index b7af68d0..a031187a 100644 --- a/test/Mocks/MockHttpService/Matchers/JsonHttpBodyMatcherTest.php +++ b/test/Mocks/MockHttpService/Matchers/JsonHttpBodyMatcherTest.php @@ -13,7 +13,8 @@ class JsonHttpBodyMatcherTest extends TestCase { - public function testMatch() { + public function testMatch() + { $matcher = new \PhpPact\Mocks\MockHttpService\Matchers\JsonHttpBodyMatcher(false); $expected = array(); @@ -33,7 +34,7 @@ public function testMatch() { $actual = array(); $actual[] = "Test"; $matcher->Match("/", $expected, $actual); - }catch (\Exception $e) { + } catch (\Exception $e) { $hasException = true; } $this->assertTrue($hasException, "Expect an exception when expected is a string"); @@ -103,5 +104,4 @@ public function testMatch() { $checks = $result->getMatcherChecks(); $this->assertTrue(($checks[0] instanceof \PhpPact\Matchers\SuccessfulMatcherCheck), "This should be a successful match - new objects allowed in current config"); } - } diff --git a/test/Mocks/MockHttpService/Matchers/SerializeHttpBodyMatcherTest.php b/test/Mocks/MockHttpService/Matchers/SerializeHttpBodyMatcherTest.php index 7f0442db..a688ead5 100644 --- a/test/Mocks/MockHttpService/Matchers/SerializeHttpBodyMatcherTest.php +++ b/test/Mocks/MockHttpService/Matchers/SerializeHttpBodyMatcherTest.php @@ -12,7 +12,8 @@ class SerializeHttpBodyMatcherTest extends TestCase { - public function testMatch() { + public function testMatch() + { $matcher = new \PhpPact\Mocks\MockHttpService\Matchers\SerializeHttpBodyMatcher(); $result = $matcher->Match("/", 'a', 'a'); @@ -37,7 +38,7 @@ public function testMatch() { $b[0] = "Zero"; $b[1] = "One"; - $result = $matcher->Match("/", $a , $b); + $result = $matcher->Match("/", $a, $b); $checks = $result->getMatcherChecks(); $this->assertTrue(($checks[0] instanceof \PhpPact\Matchers\SuccessfulMatcherCheck), "This should be a successful array match"); @@ -50,7 +51,7 @@ public function testMatch() { $b->Zero = 0; $b->One = array(1, 2); - $result = $matcher->Match("/", $a , $b); + $result = $matcher->Match("/", $a, $b); $checks = $result->getMatcherChecks(); $this->assertTrue(($checks[0] instanceof \PhpPact\Matchers\SuccessfulMatcherCheck), "This should be a successful object match"); @@ -62,10 +63,8 @@ public function testMatch() { $b = new \stdClass(); $b->One = array(1, 3); - $result = $matcher->Match("/", $a , $b); + $result = $matcher->Match("/", $a, $b); $checks = $result->getMatcherChecks(); $this->assertTrue(($checks[0] instanceof \PhpPact\Matchers\FailedMatcherCheck), "This should be a failed object match"); - } - } diff --git a/test/Mocks/MockHttpService/MockProviderHostTest.php b/test/Mocks/MockHttpService/MockProviderHostTest.php index 7da948aa..c7a1e0c1 100644 --- a/test/Mocks/MockHttpService/MockProviderHostTest.php +++ b/test/Mocks/MockHttpService/MockProviderHostTest.php @@ -13,7 +13,6 @@ class MockProviderHostTest extends TestCase { - public function testHandle() { @@ -65,15 +64,9 @@ public function testHandle() $hasException = false; try { $response = $server->handle($httpRequest); // $foo - } - catch (\Exception $e) - { + } catch (\Exception $e) { $hasException = true; } $this->assertTrue($hasException, "We apply different headers and expect an error to be thrown."); - - - - } } diff --git a/test/Mocks/MockHttpService/MockProviderServiceTest.php b/test/Mocks/MockHttpService/MockProviderServiceTest.php index bc52051c..fcda7736 100644 --- a/test/Mocks/MockHttpService/MockProviderServiceTest.php +++ b/test/Mocks/MockHttpService/MockProviderServiceTest.php @@ -24,7 +24,7 @@ public function testWith() $hasException = false; try { $mockProviderService->With($request); - }catch(Exception $e) { + } catch (Exception $e) { $hasException = true; } $this->assertFalse($hasException, "Happy path with a get request"); @@ -35,7 +35,7 @@ public function testWith() $hasException = false; try { $mockProviderService->With($request); - }catch(\InvalidArgumentException $e) { + } catch (\InvalidArgumentException $e) { $hasException = true; } $this->assertTrue($hasException, "An exception is thrown if the method is not set"); @@ -45,11 +45,9 @@ public function testWith() $hasException = false; try { $mockProviderService->With($request); - }catch(\InvalidArgumentException $e) { + } catch (\InvalidArgumentException $e) { $hasException = true; } $this->assertTrue($hasException, "An exception is thrown if the object is not a ProviderServiceRequest"); } - - } diff --git a/test/Mocks/MockHttpService/Models/HttpVerbTest.php b/test/Mocks/MockHttpService/Models/HttpVerbTest.php index 71749895..d21b9e3e 100644 --- a/test/Mocks/MockHttpService/Models/HttpVerbTest.php +++ b/test/Mocks/MockHttpService/Models/HttpVerbTest.php @@ -5,7 +5,8 @@ class HttpVerbTest extends TestCase { - public function testEnum() { + public function testEnum() + { $verb = new HttpVerb(); $this->assertEquals(HttpVerb::GET, $verb->Enum('GeT'), 'Ensure we handle case appropriately.'); diff --git a/test/Mocks/MockHttpService/Models/ProviderServicePactFileTest.php b/test/Mocks/MockHttpService/Models/ProviderServicePactFileTest.php index 98ca069f..f7f57aee 100644 --- a/test/Mocks/MockHttpService/Models/ProviderServicePactFileTest.php +++ b/test/Mocks/MockHttpService/Models/ProviderServicePactFileTest.php @@ -52,7 +52,6 @@ public function testFilterInteractionsByDescription() $actualInteractions = $pactFile->getInteractions(); $this->assertEquals(0, count($actualInteractions), "No interactions returned"); - } public function testFilterInteractionsByProviderState() @@ -124,6 +123,4 @@ public function testSetInteractions() $this->assertEquals("A GET request", $actualInteraction1->getDescription(), "Check that an interaction has a description"); $this->assertEquals("Some types", $actualInteraction1->getProviderState(), "Check that an interaction has a provider state"); } - - } diff --git a/test/Models/PactFileTest.php b/test/Models/PactFileTest.php index 4f142c8a..d635db18 100644 --- a/test/Models/PactFileTest.php +++ b/test/Models/PactFileTest.php @@ -8,7 +8,8 @@ class PactFileTest extends TestCase { - public function testSetMetadata() { + public function testSetMetadata() + { $f = new PactFile(); $m = $f->getMetadata(); @@ -17,7 +18,7 @@ public function testSetMetadata() { $thrownException = false; try { $f->setMetadata("fail now"); - }catch(\Exception $e) { + } catch (\Exception $e) { $thrownException = true; } $this->assertTrue($thrownException, "Ensure an exception is thrown if the proper object is not passed"); @@ -26,7 +27,7 @@ public function testSetMetadata() { try { $o = new \stdClass(); $f->setMetadata($o); - }catch(\Exception $e) { + } catch (\Exception $e) { $thrownException = true; } $this->assertTrue($thrownException, "Ensure an exception is thrown if the proper object is without a pactSpecificationVersion"); @@ -36,7 +37,7 @@ public function testSetMetadata() { $o = new \stdClass(); $o->pactSpecificationVersion = '2.0'; $m = $f->setMetadata($o); - }catch(\Exception $e) { + } catch (\Exception $e) { $thrownException = true; } $this->assertFalse($thrownException, "A proper object is set"); @@ -48,7 +49,7 @@ public function testSetMetadata() { $o->metadata = new \stdClass(); $o->metadata->pactSpecificationVersion = '3.0'; $m = $f->setMetadata($o); - }catch(\Exception $e) { + } catch (\Exception $e) { $thrownException = true; } $this->assertFalse($thrownException, "A proper object is set"); diff --git a/test/Models/PacticipantTest.php b/test/Models/PacticipantTest.php index 9d175736..f5739fdb 100644 --- a/test/Models/PacticipantTest.php +++ b/test/Models/PacticipantTest.php @@ -13,8 +13,8 @@ class PacticipantTest extends TestCase { - - public function testSetName() { + public function testSetName() + { $p = new \PhpPact\Models\Pacticipant(); $actual = $p->setName("MyName"); diff --git a/test/Models/ProviderStatesTest.php b/test/Models/ProviderStatesTest.php index d2e0a9aa..519b7c14 100644 --- a/test/Models/ProviderStatesTest.php +++ b/test/Models/ProviderStatesTest.php @@ -5,7 +5,8 @@ class ProviderStatesTest extends TestCase { - public function testAdd() { + public function testAdd() + { $providerStates = new ProviderStates(); $providerStates->Add("State 1"); @@ -13,8 +14,7 @@ public function testAdd() { $throwException = false; try { $providerStates->Add("State 1"); - } - catch (Exception $e) { + } catch (Exception $e) { $throwException = true; } diff --git a/test/PactBuilderTest.php b/test/PactBuilderTest.php index 3290fff8..e466f8f5 100644 --- a/test/PactBuilderTest.php +++ b/test/PactBuilderTest.php @@ -58,14 +58,10 @@ public function testBuild() $build->Build($pactFile); $expectedFile = self::TEMP_PACT_DIR . '/' . $pactFile->getFileName(); $this->assertTrue(file_exists($expectedFile), sprintf("We expect pact file to be written: %s", $pactFile->getFileName())); - } catch (\PhpPact\PactFailureException $e) { $hasException = true; } $this->assertFalse($hasException, "This basic get should verify the interactions and not throw an exception"); // assert no exception - - } - } diff --git a/test/PactVerifierConfigTest.php b/test/PactVerifierConfigTest.php index 01e005a4..4ea3459b 100644 --- a/test/PactVerifierConfigTest.php +++ b/test/PactVerifierConfigTest.php @@ -5,8 +5,8 @@ class PactVerifierConfigTest extends TestCase { - - public function testSetBaseUri() { + public function testSetBaseUri() + { $config = new PactVerifierConfig(); $config->setBaseUri('localhost'); @@ -29,25 +29,25 @@ public function testSetBaseUri() { $actual = $config->getBaseUri(); $this->assertEquals('https://localhost:123', $actual, 'Ensure https has a custom port'); - $config->setBaseUri('http://google.com', 123 ); + $config->setBaseUri('http://google.com', 123); $actual = $config->getBaseUri(); $this->assertEquals('http://google.com:123', $actual, 'Ensure http has a custom port on google'); $this->assertEquals("google.com", $config->getBaseUrn(), "Ensure URN is properly set"); $this->assertEquals("123", $config->getPort(), "Ensure port is properly set"); - $config->setBaseUri('https://127.0.10.13:333/', 333, 'https' ); + $config->setBaseUri('https://127.0.10.13:333/', 333, 'https'); $actual = $config->getBaseUri(); $this->assertEquals('https://127.0.10.13:333', $actual, 'Ensure IPs work along with keeping a core https override'); $this->assertEquals("127.0.10.13", $config->getBaseUrn(), "Ensure URN is properly set"); $this->assertEquals("333", $config->getPort(), "Ensure port is properly set"); - $config->setBaseUri('https://127.0.10.13:222/', 333, 'https' ); + $config->setBaseUri('https://127.0.10.13:222/', 333, 'https'); $actual = $config->getBaseUri(); $this->assertEquals('https://127.0.10.13:222', $actual, 'The port embedded in the URL trumps what is passed in'); $this->assertEquals("127.0.10.13", $config->getBaseUrn(), "Ensure URN is properly set"); $this->assertEquals("222", $config->getPort(), "Ensure port is properly set"); - $config->setBaseUri('http://127.0.10.13:333/', 333, 'https' ); + $config->setBaseUri('http://127.0.10.13:333/', 333, 'https'); $actual = $config->getBaseUri(); $this->assertEquals('http://127.0.10.13:333', $actual, 'The protocol embedded in the URL trumps what is passed in'); $this->assertEquals("127.0.10.13", $config->getBaseUrn(), "Ensure URN is properly set"); diff --git a/test/bootstrap.php b/test/bootstrap.php index f1eb5a3e..590aae55 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -1,7 +1,7 @@