Skip to content

Commit dee2d87

Browse files
committed
Merge pull request #1 from estahn/analysis-qyv21Y
Applied fixes from StyleCI
2 parents 44b215e + e0ab672 commit dee2d87

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

src/Assert.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use JsonSchema\Validator;
1717

1818
/**
19-
* Asserts to validate JSON data
19+
* Asserts to validate JSON data.
2020
*
2121
* - All assert methods expect deserialised JSON data (an actual object or array)
2222
* since the deserialisation method should be up to the user.
@@ -25,7 +25,7 @@
2525
trait Assert
2626
{
2727
/**
28-
* Asserts that json content is valid according to the provided schema file
28+
* Asserts that json content is valid according to the provided schema file.
2929
*
3030
* Example:
3131
*
@@ -37,10 +37,10 @@ trait Assert
3737
public static function assertJsonMatchesSchema($schema, $content)
3838
{
3939
$retriever = new UriRetriever();
40-
$schema = $retriever->retrieve('file://' . realpath($schema));
40+
$schema = $retriever->retrieve('file://'.realpath($schema));
4141

4242
$refResolver = new RefResolver($retriever);
43-
$refResolver->resolve($schema, 'file://' . __DIR__ . '/../Resources/schemas/');
43+
$refResolver->resolve($schema, 'file://'.__DIR__.'/../Resources/schemas/');
4444

4545
$validator = new Validator();
4646
$validator->check($content, $schema);
@@ -49,13 +49,13 @@ public static function assertJsonMatchesSchema($schema, $content)
4949
$messages = array_map(function ($e) use ($message) {
5050
return sprintf($message, $e['property'], $e['constraint'], $e['message']);
5151
}, $validator->getErrors());
52-
$messages[] = '- Response: ' . json_encode($content);
52+
$messages[] = '- Response: '.json_encode($content);
5353

5454
self::assertTrue($validator->isValid(), implode("\n", $messages));
5555
}
5656

5757
/**
58-
* Asserts that json content is valid according to the provided schema string
58+
* Asserts that json content is valid according to the provided schema string.
5959
*
6060
* @param string $schema Schema data
6161
* @param array|object $content JSON content
@@ -69,7 +69,7 @@ public static function assertJsonMatchesSchemaString($schema, $content)
6969
}
7070

7171
/**
72-
* Asserts if the value retrieved with the expression equals the expected value
72+
* Asserts if the value retrieved with the expression equals the expected value.
7373
*
7474
* Example:
7575
*
@@ -90,6 +90,7 @@ public static function assertJsonValueEquals($expected, $expression, $json)
9090
/**
9191
* @param $expression
9292
* @param $data
93+
*
9394
* @return mixed|null
9495
*/
9596
public static function search($expression, $data)
@@ -98,13 +99,14 @@ public static function search($expression, $data)
9899
}
99100

100101
/**
101-
* Helper method to deserialise a JSON string into an object
102+
* Helper method to deserialise a JSON string into an object.
102103
*
103104
* @param mixed $data The JSON string
105+
*
104106
* @return array|object
105107
*/
106108
public static function getJsonObject($data)
107109
{
108110
return (is_array($data) || is_object($data)) ? $data : json_decode($data);
109111
}
110-
}
112+
}

src/AssertClass.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
<?php
22

3+
/*
4+
* This file is part of the phpunit-json-assertions package.
5+
*
6+
* (c) Enrico Stahn <enrico.stahn@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace EnricoStahn\JsonAssert;
413

514
class AssertClass extends \PHPUnit_Framework_TestCase
615
{
716
use Assert;
8-
}
17+
}

tests/AssertTraitImpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
class AssertTraitImpl extends \PHPUnit_Framework_TestCase
1717
{
1818
use JsonAssert;
19-
}
19+
}

tests/AssertTraitTest.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the phpunit-json-assertions package.
5+
*
6+
* (c) Enrico Stahn <enrico.stahn@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace EnricoStahn\JsonAssert\Tests;
413

514
class AssertTraitTest extends \PHPUnit_Framework_TestCase
@@ -48,12 +57,12 @@ public function testAssertJsonSchemaFailMessage()
4857
}
4958

5059
/**
51-
* Tests assertJsonValueEquals()
60+
* Tests assertJsonValueEquals().
5261
*
5362
* @dataProvider assertJsonValueEqualsProvider
5463
*
5564
* @param string $expression
56-
* @param mixed $value
65+
* @param mixed $value
5766
*/
5867
public function testAssertJsonValueEquals($expression, $value)
5968
{
@@ -66,7 +75,7 @@ public function assertJsonValueEqualsProvider()
6675
{
6776
return [
6877
['foo', '123'],
69-
['a.b.c[0].d[1][0]', 1]
78+
['a.b.c[0].d[1][0]', 1],
7079
];
7180
}
7281

@@ -94,8 +103,7 @@ public function testGetJsonObjectProvider()
94103
[[], []],
95104
[[], '[]'],
96105
[new \stdClass(), new \stdClass()],
97-
[new \stdClass(), '{}']
106+
[new \stdClass(), '{}'],
98107
];
99108
}
100-
101109
}

0 commit comments

Comments
 (0)