Skip to content

Commit c1292b8

Browse files
Support PHPUnit 8
1 parent 2222d9e commit c1292b8

File tree

7 files changed

+21
-23
lines changed

7 files changed

+21
-23
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ schemas.
1212

1313
## Author and copyright
1414

15-
Martin Helmich <kontakt@martin-helmich.de>
15+
Martin Helmich <kontakt@martin-helmich.de>
1616
This library is [MIT-licensed](LICENSE.txt).
1717

1818
## Installation
@@ -23,10 +23,11 @@ This library is [MIT-licensed](LICENSE.txt).
2323

2424
There are several release branches of this library, each of these being compatible with different releases of PHPUnit and PHP. The following table should give an easy overview:
2525

26-
| "JSON assertion" version | PHPUnit 4 | PHPUnit 5 | PHPUnit 6 | PHPUnit 7 |
26+
| "JSON assertion" version | PHPUnit 4 | PHPUnit 5 | PHPUnit 6 | PHPUnit 7 | PHPUnit 8 |
2727
| ------------------------ | --------- | --------- | --------- | --------- |
28-
| v1 (branch `v1`), **unsupported** | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: |
29-
| v2 (branch `master`) | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: |
28+
| v1 (branch `v1`), **unsupported** | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: |
29+
| v2 (branch `v2`) | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :no_entry_sign: |
30+
| v3 (branch `master`) | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: |
3031

3132
When you are using `composer require` and have already declared a dependency to `phpunit/phpunit` in your `composer.json` file, Composer should pick latest compatible version automatically.
3233

src/Constraint/JsonValueMatches.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ class JsonValueMatches extends Constraint
4141
*/
4242
public function __construct(string $jsonPath, Constraint $constraint, bool $matchAll = false)
4343
{
44-
parent::__construct();
45-
4644
$this->jsonPath = $jsonPath;
4745
$this->constraint = $constraint;
4846
$this->matchAll = $matchAll;

src/Constraint/JsonValueMatchesMany.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class JsonValueMatchesMany extends Constraint
2727
*/
2828
public function __construct(array $constraints)
2929
{
30-
parent::__construct();
31-
3230
foreach ($constraints as $key => $constraint) {
3331
if (!$constraint instanceof Constraint) {
3432
$constraint = new IsEqual($constraint);

src/Constraint/JsonValueMatchesSchema.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class JsonValueMatchesSchema extends Constraint
2525
*/
2626
public function __construct($schema)
2727
{
28-
parent::__construct();
2928
$this->schema = $this->forceToObject($schema);
3029
}
3130

tests/Functional/JsonValueMatchesSchemaFluentTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Helmich\JsonAssert\Tests\Functional;
33

44
use Helmich\JsonAssert\JsonAssertions;
5+
use PHPUnit\Framework\AssertionFailedError;
56
use PHPUnit\Framework\TestCase;
67

78
class JsonValueMatchesSchemaFluentTest extends TestCase
@@ -59,11 +60,10 @@ public function testJsonDocumentMatchesSchema()
5960
]));
6061
}
6162

62-
/**
63-
* @expectedException \PHPUnit\Framework\AssertionFailedError
64-
*/
6563
public function testJsonDocumentDoesNotMatchSchema()
6664
{
65+
$this->expectException(AssertionFailedError::class);
66+
6767
assertThat(static::$exampleDocument, matchesJsonSchema([
6868
'type' => 'object',
6969
'required' => ['foobar'],
@@ -72,4 +72,4 @@ public function testJsonDocumentDoesNotMatchSchema()
7272
]
7373
]));
7474
}
75-
}
75+
}

tests/Functional/JsonValueMatchesSchemaTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Helmich\JsonAssert\Tests\Functional;
33

44
use Helmich\JsonAssert\JsonAssertions;
5+
use PHPUnit\Framework\AssertionFailedError;
56
use PHPUnit\Framework\TestCase;
67

78
class JsonValueMatchesSchemaTest extends TestCase
@@ -59,11 +60,10 @@ public function testJsonDocumentMatchesSchema()
5960
]);
6061
}
6162

62-
/**
63-
* @expectedException \PHPUnit\Framework\AssertionFailedError
64-
*/
6563
public function testJsonDocumentDoesNotMatchSchema()
6664
{
65+
$this->expectException(AssertionFailedError::class);
66+
6767
$this->assertJsonDocumentMatchesSchema(static::$exampleDocument, [
6868
'type' => 'object',
6969
'required' => ['foobar'],
@@ -83,4 +83,4 @@ public function testStringsAreInterpretedAsJsonString()
8383
]
8484
]);
8585
}
86-
}
86+
}

tests/Functional/JsonValueMatchesTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Helmich\JsonAssert\Tests\Functional;
33

44
use Helmich\JsonAssert\JsonAssertions;
5+
use PHPUnit\Framework\AssertionFailedError;
56
use PHPUnit\Framework\Constraint\Count;
67
use PHPUnit\Framework\Constraint\IsEqual;
78
use PHPUnit\Framework\Constraint\IsType;
@@ -82,10 +83,11 @@ public function testJsonValueEqualsCanSucceed($jsonDocument, $jsonPath, $expecte
8283
* @param $jsonPath
8384
* @param $expectedValue
8485
* @dataProvider dataForJsonValueEqualsCanFail
85-
* @expectedException \PHPUnit\Framework\AssertionFailedError
8686
*/
8787
public function testJsonValueEqualsCanFail($jsonDocument, $jsonPath, $expectedValue)
8888
{
89+
$this->expectException(AssertionFailedError::class);
90+
8991
$this->assertJsonValueEquals($jsonDocument, $jsonPath, $expectedValue);
9092
}
9193

@@ -118,10 +120,11 @@ public function testJsonValueMatchesSucceedsWithAnyConstraint()
118120
* @param $jsonPath
119121
* @param $expectedValue
120122
* @dataProvider dataForJsonValueEqualsCanFail
121-
* @expectedException \PHPUnit\Framework\AssertionFailedError
122123
*/
123124
public function testJsonValueMatchesCanFail($jsonDocument, $jsonPath, $expectedValue)
124125
{
126+
$this->expectException(AssertionFailedError::class);
127+
125128
$this->assertJsonValueMatches(
126129
$jsonDocument,
127130
$jsonPath,
@@ -146,11 +149,10 @@ public function testAssertManyCanSucceed()
146149
);
147150
}
148151

149-
/**
150-
* @expectedException \PHPUnit\Framework\AssertionFailedError
151-
*/
152152
public function testAssertManyCanFail()
153153
{
154+
$this->expectException(AssertionFailedError::class);
155+
154156
$this->assertJsonDocumentMatches(
155157
static::$exampleDocument,
156158
[
@@ -160,4 +162,4 @@ public function testAssertManyCanFail()
160162
]
161163
);
162164
}
163-
}
165+
}

0 commit comments

Comments
 (0)