diff --git a/src/Assert.php b/src/Assert.php index a548a67..dffc78d 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -16,7 +16,7 @@ use JsonSchema\Validator; /** - * Asserts to validate JSON data + * Asserts to validate JSON data. * * - All assert methods expect deserialised JSON data (an actual object or array) * since the deserialisation method should be up to the user. @@ -25,7 +25,7 @@ trait Assert { /** - * Asserts that json content is valid according to the provided schema file + * Asserts that json content is valid according to the provided schema file. * * Example: * @@ -37,10 +37,10 @@ trait Assert public static function assertJsonMatchesSchema($schema, $content) { $retriever = new UriRetriever(); - $schema = $retriever->retrieve('file://' . realpath($schema)); + $schema = $retriever->retrieve('file://'.realpath($schema)); $refResolver = new RefResolver($retriever); - $refResolver->resolve($schema, 'file://' . __DIR__ . '/../Resources/schemas/'); + $refResolver->resolve($schema, 'file://'.__DIR__.'/../Resources/schemas/'); $validator = new Validator(); $validator->check($content, $schema); @@ -49,13 +49,13 @@ public static function assertJsonMatchesSchema($schema, $content) $messages = array_map(function ($e) use ($message) { return sprintf($message, $e['property'], $e['constraint'], $e['message']); }, $validator->getErrors()); - $messages[] = '- Response: ' . json_encode($content); + $messages[] = '- Response: '.json_encode($content); self::assertTrue($validator->isValid(), implode("\n", $messages)); } /** - * Asserts that json content is valid according to the provided schema string + * Asserts that json content is valid according to the provided schema string. * * @param string $schema Schema data * @param array|object $content JSON content @@ -69,7 +69,7 @@ public static function assertJsonMatchesSchemaString($schema, $content) } /** - * Asserts if the value retrieved with the expression equals the expected value + * Asserts if the value retrieved with the expression equals the expected value. * * Example: * @@ -90,6 +90,7 @@ public static function assertJsonValueEquals($expected, $expression, $json) /** * @param $expression * @param $data + * * @return mixed|null */ public static function search($expression, $data) @@ -98,13 +99,14 @@ public static function search($expression, $data) } /** - * Helper method to deserialise a JSON string into an object + * Helper method to deserialise a JSON string into an object. * * @param mixed $data The JSON string + * * @return array|object */ public static function getJsonObject($data) { return (is_array($data) || is_object($data)) ? $data : json_decode($data); } -} \ No newline at end of file +} diff --git a/src/AssertClass.php b/src/AssertClass.php index e61a4ed..47c0f04 100644 --- a/src/AssertClass.php +++ b/src/AssertClass.php @@ -1,8 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace EnricoStahn\JsonAssert; class AssertClass extends \PHPUnit_Framework_TestCase { use Assert; -} \ No newline at end of file +} diff --git a/tests/AssertTraitImpl.php b/tests/AssertTraitImpl.php index 5ebd023..c69b6d6 100644 --- a/tests/AssertTraitImpl.php +++ b/tests/AssertTraitImpl.php @@ -16,4 +16,4 @@ class AssertTraitImpl extends \PHPUnit_Framework_TestCase { use JsonAssert; -} \ No newline at end of file +} diff --git a/tests/AssertTraitTest.php b/tests/AssertTraitTest.php index 6f7e874..98a529a 100644 --- a/tests/AssertTraitTest.php +++ b/tests/AssertTraitTest.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace EnricoStahn\JsonAssert\Tests; class AssertTraitTest extends \PHPUnit_Framework_TestCase @@ -48,12 +57,12 @@ public function testAssertJsonSchemaFailMessage() } /** - * Tests assertJsonValueEquals() + * Tests assertJsonValueEquals(). * * @dataProvider assertJsonValueEqualsProvider * * @param string $expression - * @param mixed $value + * @param mixed $value */ public function testAssertJsonValueEquals($expression, $value) { @@ -66,7 +75,7 @@ public function assertJsonValueEqualsProvider() { return [ ['foo', '123'], - ['a.b.c[0].d[1][0]', 1] + ['a.b.c[0].d[1][0]', 1], ]; } @@ -94,8 +103,7 @@ public function testGetJsonObjectProvider() [[], []], [[], '[]'], [new \stdClass(), new \stdClass()], - [new \stdClass(), '{}'] + [new \stdClass(), '{}'], ]; } - }