@@ -101,8 +101,8 @@ |
||
| 101 | 101 | */ |
| 102 | 102 | public function iSetBasicAuthenticationWithAnd($username, $password) |
| 103 | 103 | { |
| 104 | - $authorization = base64_encode($username . ':' . $password); |
|
| 105 | - $this->restApiBrowser->setRequestHeader('Authorization', 'Basic ' . $authorization); |
|
| 104 | + $authorization = base64_encode($username.':'.$password); |
|
| 105 | + $this->restApiBrowser->setRequestHeader('Authorization', 'Basic '.$authorization); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -6,8 +6,6 @@ |
||
| 6 | 6 | use Behat\Behat\Context\Context; |
| 7 | 7 | use Behat\Behat\Context\SnippetAcceptingContext; |
| 8 | 8 | use Behat\Gherkin\Node\PyStringNode; |
| 9 | -use Behat\Gherkin\Node\TableNode; |
|
| 10 | -use Psr\Http\Message\RequestInterface; |
|
| 11 | 9 | use Psr\Http\Message\ResponseInterface; |
| 12 | 10 | use Rezzza\RestApiBehatExtension\Rest\RestApiBrowser; |
| 13 | 11 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 9 | 9 | use Symfony\Component\HttpFoundation\Request; |
| 10 | 10 | |
| 11 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 11 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 12 | 12 | |
| 13 | 13 | $app = new Silex\Application(); |
| 14 | 14 | |
@@ -56,15 +56,15 @@ discard block |
||
| 56 | 56 | ); |
| 57 | 57 | $app->match( |
| 58 | 58 | 'error_random', |
| 59 | - function (Request $request) { |
|
| 60 | - $statusCode = time() % 3 <= 0 ? 200 : 502 ; |
|
| 59 | + function(Request $request) { |
|
| 60 | + $statusCode = time() % 3 <= 0 ? 200 : 502; |
|
| 61 | 61 | |
| 62 | 62 | return new JsonResponse([], $statusCode); |
| 63 | 63 | } |
| 64 | 64 | ); |
| 65 | 65 | $app->match( |
| 66 | 66 | 'always_error', |
| 67 | - function (Request $request) { |
|
| 67 | + function(Request $request) { |
|
| 68 | 68 | return new JsonResponse([], 502); |
| 69 | 69 | } |
| 70 | 70 | ); |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | public function load(ContainerBuilder $container, array $config) |
| 16 | 16 | { |
| 17 | 17 | $container->setParameter('rezzza.json_api.rest.base_url', $config['rest']['base_url']); |
| 18 | - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/Resources')); |
|
| 18 | + $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/Resources')); |
|
| 19 | 19 | $loader->load('services.xml'); |
| 20 | 20 | |
| 21 | 21 | if (true === $config['rest']['store_response']) { |
@@ -19,15 +19,15 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function validate(Json $json, Validator $validator, SchemaStorage $schemaStorage) |
| 21 | 21 | { |
| 22 | - $schema = $schemaStorage->resolveRef('file://' . realpath($this->filename)); |
|
| 22 | + $schema = $schemaStorage->resolveRef('file://'.realpath($this->filename)); |
|
| 23 | 23 | $data = $json->getRawContent(); |
| 24 | 24 | |
| 25 | 25 | $validator->check($data, $schema); |
| 26 | 26 | |
| 27 | 27 | if (!$validator->isValid()) { |
| 28 | - $msg = "JSON does not validate. Violations:" . PHP_EOL; |
|
| 28 | + $msg = "JSON does not validate. Violations:".PHP_EOL; |
|
| 29 | 29 | foreach ($validator->getErrors() as $error) { |
| 30 | - $msg .= sprintf(" - [%s] %s" . PHP_EOL, $error['property'], $error['message']); |
|
| 30 | + $msg .= sprintf(" - [%s] %s".PHP_EOL, $error['property'], $error['message']); |
|
| 31 | 31 | } |
| 32 | 32 | throw new \Exception($msg); |
| 33 | 33 | } |
@@ -115,7 +115,7 @@ |
||
| 115 | 115 | new TimeOut(new SleepWaiter(), $maxExecutionTime) |
| 116 | 116 | ); |
| 117 | 117 | $restApiBrowser = $this; |
| 118 | - $runner->run(new Callback(function () use ($restApiBrowser, $method, $uri, $body, $assertion) { |
|
| 118 | + $runner->run(new Callback(function() use ($restApiBrowser, $method, $uri, $body, $assertion) { |
|
| 119 | 119 | $restApiBrowser->sendRequest($method, $uri, $body); |
| 120 | 120 | |
| 121 | 121 | return $assertion(); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function theJsonNodeShouldBeEqualTo($jsonNode, $expectedValue) |
| 45 | 45 | { |
| 46 | - $this->assert(function () use ($jsonNode, $expectedValue) { |
|
| 46 | + $this->assert(function() use ($jsonNode, $expectedValue) { |
|
| 47 | 47 | $realValue = $this->evaluateJsonNodeValue($jsonNode); |
| 48 | 48 | $expectedValue = $this->evaluateExpectedValue($expectedValue); |
| 49 | 49 | $this->asserter->variable($realValue)->isEqualTo($expectedValue); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function theJsonNodeShouldHaveElements($jsonNode, $expectedNth) |
| 58 | 58 | { |
| 59 | - $this->assert(function () use ($jsonNode, $expectedNth) { |
|
| 59 | + $this->assert(function() use ($jsonNode, $expectedNth) { |
|
| 60 | 60 | $realValue = $this->evaluateJsonNodeValue($jsonNode); |
| 61 | 61 | $this->asserter->phpArray($realValue)->hasSize($expectedNth); |
| 62 | 62 | }); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function theJsonArrayNodeShouldContainElements($jsonNode, $expectedValue) |
| 69 | 69 | { |
| 70 | - $this->assert(function () use ($jsonNode, $expectedValue) { |
|
| 70 | + $this->assert(function() use ($jsonNode, $expectedValue) { |
|
| 71 | 71 | $realValue = $this->evaluateJsonNodeValue($jsonNode); |
| 72 | 72 | $this->asserter->phpArray($realValue)->contains($expectedValue); |
| 73 | 73 | }); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function theJsonArrayNodeShouldNotContainElements($jsonNode, $expectedValue) |
| 80 | 80 | { |
| 81 | - $this->assert(function () use ($jsonNode, $expectedValue) { |
|
| 81 | + $this->assert(function() use ($jsonNode, $expectedValue) { |
|
| 82 | 82 | $realValue = $this->evaluateJsonNodeValue($jsonNode); |
| 83 | 83 | $this->asserter->phpArray($realValue)->notContains($expectedValue); |
| 84 | 84 | }); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function theJsonNodeShouldContain($jsonNode, $expectedValue) |
| 91 | 91 | { |
| 92 | - $this->assert(function () use ($jsonNode, $expectedValue) { |
|
| 92 | + $this->assert(function() use ($jsonNode, $expectedValue) { |
|
| 93 | 93 | $realValue = $this->evaluateJsonNodeValue($jsonNode); |
| 94 | 94 | $this->asserter->string((string) $realValue)->contains($expectedValue); |
| 95 | 95 | }); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function theJsonNodeShouldNotContain($jsonNode, $unexpectedValue) |
| 104 | 104 | { |
| 105 | - $this->assert(function () use ($jsonNode, $unexpectedValue) { |
|
| 105 | + $this->assert(function() use ($jsonNode, $unexpectedValue) { |
|
| 106 | 106 | $realValue = $this->evaluateJsonNodeValue($jsonNode); |
| 107 | 107 | $this->asserter->string((string) $realValue)->notContains($unexpectedValue); |
| 108 | 108 | }); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | { |
| 154 | 154 | $tempFilename = tempnam(sys_get_temp_dir(), 'rae'); |
| 155 | 155 | file_put_contents($tempFilename, $jsonSchemaContent); |
| 156 | - $this->assert(function () use ($tempFilename) { |
|
| 156 | + $this->assert(function() use ($tempFilename) { |
|
| 157 | 157 | $this->jsonInspector->validateJson( |
| 158 | 158 | new JsonSchema($tempFilename) |
| 159 | 159 | ); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | { |
| 169 | 169 | $filename = $this->resolveFilename($filename); |
| 170 | 170 | |
| 171 | - $this->assert(function () use ($filename) { |
|
| 171 | + $this->assert(function() use ($filename) { |
|
| 172 | 172 | $this->jsonInspector->validateJson( |
| 173 | 173 | new JsonSchema($filename) |
| 174 | 174 | ); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | throw new \Exception('The expected JSON is not a valid'); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - $this->assert(function () use ($realJsonValue, $expectedJsonValue) { |
|
| 191 | + $this->assert(function() use ($realJsonValue, $expectedJsonValue) { |
|
| 192 | 192 | $this->asserter->castToString($realJsonValue)->isEqualTo((string) $expectedJsonValue); |
| 193 | 193 | }); |
| 194 | 194 | } |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | )); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $filename = $this->jsonSchemaBaseUrl . '/' . $filename; |
|
| 269 | + $filename = $this->jsonSchemaBaseUrl.'/'.$filename; |
|
| 270 | 270 | |
| 271 | 271 | if (false === is_file($filename)) { |
| 272 | 272 | throw new \RuntimeException(sprintf( |