Skip to content

Commit 90241b0

Browse files
Mabiroestahn
authored andcommitted
New version to support phpunit 6 (#15)
* Added phpunit6 support * Fixed PHP versions for travis ci * fix: DataProvider for testGetJsonObject wasn't working * ci: Remove non-required travis statements
1 parent 11fd0e8 commit 90241b0

File tree

11 files changed

+37
-35
lines changed

11 files changed

+37
-35
lines changed

.travis.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,8 @@ sudo: false
33
language: php
44

55
php:
6-
- 5.4
7-
- 5.5
8-
- 5.6
9-
- 7
10-
- hhvm
11-
12-
matrix:
13-
include:
14-
- php: 5.4
15-
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
16-
allow_failures:
17-
- php: hhvm
6+
- 7.1
7+
- 7.2
188

199
before_script:
2010
- travis_retry composer self-update

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ You can either use the `trait` or `class` version.
5757
namespace EnricoStahn\JsonAssert\Tests;
5858

5959
use EnricoStahn\JsonAssert\Assert as JsonAssert;
60+
use PHPUnit\Framework\TestCase;
6061

61-
class MyTestCase extends \PHPUnit_Framework_TestCase
62+
class MyTestCase extends TestCase
6263
{
6364
use JsonAssert;
6465

@@ -86,7 +87,7 @@ class MyTestCase extends \PHPUnit_Framework_TestCase
8687

8788
### Class
8889

89-
In case you don't want to use the `trait` you can use the provided class wich extends from `\PHPUnit_Framework_TestCase`.
90+
In case you don't want to use the `trait` you can use the provided class wich extends from `PHPUnit\Framework\TestCase`.
9091
You can either extend your test case or use the static methods like below.
9192

9293
```php
@@ -95,8 +96,9 @@ You can either extend your test case or use the static methods like below.
9596
namespace EnricoStahn\JsonAssert\Tests;
9697

9798
use EnricoStahn\JsonAssert\AssertClass as JsonAssert;
99+
use PHPUnit\Framework\TestCase;
98100

99-
class MyTestCase extends \PHPUnit_Framework_TestCase
101+
class MyTestCase extends TestCase
100102
{
101103
public function testJsonDocumentIsValid()
102104
{

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
],
1414
"minimum-stability": "stable",
1515
"require": {
16-
"php": "^5.4 || ^7.0",
16+
"php": "^7.0",
1717
"justinrainbow/json-schema": "^2.0",
1818
"mtdowling/jmespath.php": "^2.3"
1919
},
2020
"require-dev": {
21-
"phpunit/phpunit": "~4.8|~5.2",
21+
"phpunit/phpunit": "^6",
2222
"codacy/coverage": "dev-master",
2323
"symfony/http-foundation": "^2.8|^3.0"
2424
},

src/Assert.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function assertJsonMatchesSchema($schema, $content)
5151
}, $validator->getErrors());
5252
$messages[] = '- Response: '.json_encode($content);
5353

54-
\PHPUnit_Framework_Assert::assertTrue($validator->isValid(), implode("\n", $messages));
54+
\PHPUnit\Framework\Assert::assertTrue($validator->isValid(), implode("\n", $messages));
5555
}
5656

5757
/**
@@ -84,8 +84,8 @@ public static function assertJsonValueEquals($expected, $expression, $json)
8484
{
8585
$result = \JmesPath\Env::search($expression, $json);
8686

87-
\PHPUnit_Framework_Assert::assertEquals($expected, $result);
88-
\PHPUnit_Framework_Assert::assertInternalType(gettype($expected), $result);
87+
\PHPUnit\Framework\Assert::assertEquals($expected, $result);
88+
\PHPUnit\Framework\Assert::assertInternalType(gettype($expected), $result);
8989
}
9090

9191
/**

src/AssertClass.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace EnricoStahn\JsonAssert;
1313

14-
class AssertClass extends \PHPUnit_Framework_TestCase
14+
use PHPUnit\Framework\TestCase;
15+
16+
class AssertClass extends TestCase
1517
{
1618
use Assert;
1719
}

src/Extension/Symfony.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ public static function assertJsonValueEquals($expected, $expression, $response)
6969
*/
7070
public static function assertJsonResponse(Response $response, $statusCode = 200)
7171
{
72-
\PHPUnit_Framework_Assert::assertEquals(
72+
\PHPUnit\Framework\Assert::assertEquals(
7373
$statusCode,
7474
$response->getStatusCode(),
7575
$response->getContent()
7676
);
77-
\PHPUnit_Framework_Assert::assertTrue(
77+
\PHPUnit\Framework\Assert::assertTrue(
7878
$response->headers->contains('Content-Type', 'application/json'),
7979
$response->headers
8080
);

src/Extension/SymfonyClass.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace EnricoStahn\JsonAssert\Extension;
1313

14-
class SymfonyClass extends \PHPUnit_Framework_TestCase
14+
use PHPUnit\Framework\TestCase;
15+
16+
class SymfonyClass extends TestCase
1517
{
1618
use Symfony;
1719
}

tests/AssertClassTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
namespace EnricoStahn\JsonAssert\Tests;
1313

1414
use EnricoStahn\JsonAssert\AssertClass;
15+
use PHPUnit\Framework\TestCase;
1516

16-
class AssertClassTest extends \PHPUnit_Framework_TestCase
17+
class AssertClassTest extends TestCase
1718
{
1819
public function testClassInstance()
1920
{

tests/AssertTraitImpl.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
namespace EnricoStahn\JsonAssert\Tests;
1313

1414
use EnricoStahn\JsonAssert\Assert as JsonAssert;
15+
use PHPUnit\Framework\TestCase;
1516

16-
class AssertTraitImpl extends \PHPUnit_Framework_TestCase
17+
class AssertTraitImpl extends TestCase
1718
{
1819
use JsonAssert;
1920
}

tests/AssertTraitTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
namespace EnricoStahn\JsonAssert\Tests;
1313

14-
class AssertTraitTest extends \PHPUnit_Framework_TestCase
14+
use PHPUnit\Framework\ExpectationFailedException;
15+
use PHPUnit\Framework\TestCase;
16+
17+
class AssertTraitTest extends TestCase
1518
{
1619
/**
1720
* Showcase for the Wiki.
@@ -33,7 +36,7 @@ public function testAssertJsonMatchesSchema()
3336
}
3437

3538
/**
36-
* @expectedException \PHPUnit_Framework_ExpectationFailedException
39+
* @expectedException \PHPUnit\Framework\ExpectationFailedException
3740
*/
3841
public function testAssertJsonMatchesSchemaFail()
3942
{
@@ -50,12 +53,12 @@ public function testAssertJsonMatchesSchemaFailMessage()
5053

5154
try {
5255
AssertTraitImpl::assertJsonMatchesSchema(Utils::getSchemaPath('test.schema.json'), $content);
53-
} catch (\PHPUnit_Framework_ExpectationFailedException $exception) {
56+
} catch (ExpectationFailedException $exception) {
5457
self::assertContains('- Property: foo, Contraint: type, Message: String value found, but an integer is required', $exception->getMessage());
5558
self::assertContains('- Response: {"foo":"123"}', $exception->getMessage());
5659
}
5760

58-
self::assertInstanceOf('PHPUnit_Framework_ExpectationFailedException', $exception);
61+
self::assertInstanceOf('\PHPUnit\Framework\ExpectationFailedException', $exception);
5962
}
6063

6164
/**
@@ -69,7 +72,7 @@ public function testAssertJsonMatchesSchemaWithRefs()
6972
}
7073

7174
/**
72-
* @expectedException \PHPUnit_Framework_ExpectationFailedException
75+
* @expectedException \PHPUnit\Framework\ExpectationFailedException
7376
*/
7477
public function testAssertJsonMatchesSchemaWithRefsFails()
7578
{
@@ -110,7 +113,7 @@ public function assertJsonValueEqualsProvider()
110113
}
111114

112115
/**
113-
* @expectedException \PHPUnit_Framework_ExpectationFailedException
116+
* @expectedException \PHPUnit\Framework\ExpectationFailedException
114117
*/
115118
public function testAssertJsonValueEqualsFailsOnWrongDataType()
116119
{
@@ -120,14 +123,14 @@ public function testAssertJsonValueEqualsFailsOnWrongDataType()
120123
}
121124

122125
/**
123-
* @dataProvider testGetJsonObjectProvider
126+
* @dataProvider jsonObjectProvider
124127
*/
125128
public function testGetJsonObject($expected, $actual)
126129
{
127130
self::assertEquals($expected, AssertTraitImpl::getJsonObject($actual));
128131
}
129132

130-
public function testGetJsonObjectProvider()
133+
public function jsonObjectProvider()
131134
{
132135
return [
133136
[[], []],

0 commit comments

Comments
 (0)