File tree Expand file tree Collapse file tree 10 files changed +121
-15
lines changed Expand file tree Collapse file tree 10 files changed +121
-15
lines changed Original file line number Diff line number Diff line change 2
2
All notable changes to this project will be documented in this file.
3
3
4
4
The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ ) and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
5
+ ## [ 3.2.2] - 2019-02-12
6
+ ### Summary
7
+ - Change tests to resolve deprecation warnings that appear under PHPUnit 8 (#93 )
5
8
6
9
## [ 3.2.1] - 2018-10-24
7
10
### Summary
Original file line number Diff line number Diff line change 1
1
includes :
2
2
- vendor/phpstan/phpstan-phpunit/extension.neon
3
3
4
+ parameters :
5
+ ignoreErrors :
6
+ - '#Call to an undefined static method PHPUnit\\Framework\\TestCase::assertIs (Array|Bool|String )\ (\)#'
7
+ reportUnmatchedIgnoredErrors : false
Original file line number Diff line number Diff line change 17
17
trait EndpointTestCases
18
18
{
19
19
use HandlesOwnErrorsTestCases;
20
+ use Testing \PHPUnit8Shim;
20
21
use ValidationTestTrait;
21
22
22
23
/**
@@ -47,8 +48,7 @@ protected function getValidation(): ValidationInterface
47
48
public function testGetUri (string $ uri , bool $ match , array $ expectedMatches )
48
49
{
49
50
$ endpoint = $ this ->getEndpoint ();
50
- $ this ->assertInternalType (
51
- 'string ' ,
51
+ $ this ->assertIsString (
52
52
$ endpoint ->getUri (),
53
53
'getUri did not return a string '
54
54
);
Original file line number Diff line number Diff line change
1
+ <?php
2
+ declare (strict_types=1 );
3
+
4
+ namespace Firehed \API \Traits \Testing ;
5
+
6
+ /**
7
+ * phpcs:disable
8
+ *
9
+ * Implement some horrible hacks to allow PHP7.0 users to use assertIsString
10
+ * which natively has a void return type.
11
+ *
12
+ * @internal
13
+ */
14
+ if (version_compare (PHP_VERSION , '7.1.0 ' , '>= ' )) {
15
+ trait PHPUnit8Shim
16
+ {
17
+ use PHPUnit8ShimPHPGTE71;
18
+ }
19
+ } else {
20
+ trait PHPUnit8Shim
21
+ {
22
+ use PHPUnit8ShimPHPLT71;
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ declare (strict_types=1 );
3
+
4
+ namespace Firehed \API \Traits \Testing ;
5
+
6
+ use PHPUnit \Framework \TestCase ;
7
+
8
+ /**
9
+ * Create assertIsFoo static methods introduced in PHPUnit 7.5 for users with
10
+ * earlier versions
11
+ *
12
+ * @internal
13
+ */
14
+ trait PHPUnit8ShimPHPGTE71
15
+ {
16
+ public static function assertIsArray ($ actual , string $ message = '' ): void
17
+ {
18
+ if (method_exists (TestCase::class, 'assertIsArray ' )) {
19
+ TestCase::assertIsArray ($ actual , $ message );
20
+ } else {
21
+ TestCase::assertInternalType ('array ' , $ actual , $ message );
22
+ }
23
+ }
24
+
25
+ public static function assertIsBool ($ actual , string $ message = '' ): void
26
+ {
27
+ if (method_exists (TestCase::class, 'assertIsBool ' )) {
28
+ TestCase::assertIsBool ($ actual , $ message );
29
+ } else {
30
+ TestCase::assertInternalType ('bool ' , $ actual , $ message );
31
+ }
32
+ }
33
+
34
+ public static function assertIsString ($ actual , string $ message = '' ): void
35
+ {
36
+ if (method_exists (TestCase::class, 'assertIsString ' )) {
37
+ TestCase::assertIsString ($ actual , $ message );
38
+ } else {
39
+ TestCase::assertInternalType ('string ' , $ actual , $ message );
40
+ }
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ declare (strict_types=1 );
3
+
4
+ namespace Firehed \API \Traits \Testing ;
5
+
6
+ use PHPUnit \Framework \TestCase ;
7
+
8
+ /**
9
+ * PHP 7.0-compatible shim (stripped return types)
10
+ * Simply wraps assertInternalType since PHPUnit 7.5 (where the new versions
11
+ * became available) requires 7.1 or later.
12
+ *
13
+ * @internal
14
+ */
15
+ trait PHPUnit8ShimPHPLT71
16
+ {
17
+ public static function assertIsArray ($ actual , string $ message = '' )
18
+ {
19
+ TestCase::assertInternalType ('array ' , $ actual , $ message );
20
+ }
21
+
22
+ public static function assertIsBool ($ actual , string $ message = '' )
23
+ {
24
+ TestCase::assertInternalType ('bool ' , $ actual , $ message );
25
+ }
26
+
27
+ public static function assertIsString ($ actual , string $ message = '' )
28
+ {
29
+ TestCase::assertInternalType ('string ' , $ actual , $ message );
30
+ }
31
+ }
Original file line number Diff line number Diff line change 4
4
5
5
namespace Firehed \API ;
6
6
7
+ use BadMethodCallException ;
7
8
use Exception ;
8
9
use Firehed \API \Authentication ;
9
10
use Firehed \API \Authorization ;
10
11
use Firehed \API \Interfaces \EndpointInterface ;
11
12
use Firehed \API \Errors \HandlerInterface ;
13
+ use OutOfBoundsException ;
12
14
use Psr \Container \ContainerInterface ;
13
15
use Psr \Http \Message \RequestInterface ;
14
16
use Psr \Http \Message \ResponseInterface ;
@@ -425,24 +427,24 @@ public function testErrorInResponseHandler()
425
427
426
428
/**
427
429
* @covers ::dispatch
428
- * @expectedException BadMethodCallException
429
- * @expectedExceptionCode 500
430
430
*/
431
431
public function testDispatchThrowsWhenMissingData ()
432
432
{
433
433
$ d = new Dispatcher ();
434
+ $ this ->expectException (BadMethodCallException::class);
435
+ $ this ->expectExceptionCode (500 );
434
436
$ ret = $ d ->dispatch ();
435
437
}
436
438
437
439
/**
438
440
* @covers ::dispatch
439
- * @expectedException OutOfBoundsException
440
- * @expectedExceptionCode 404
441
441
*/
442
442
public function testNoRouteMatchReturns404 ()
443
443
{
444
444
$ req = $ this ->getMockRequestWithUriPath ('/ ' );
445
445
446
+ $ this ->expectException (OutOfBoundsException::class);
447
+ $ this ->expectExceptionCode (404 );
446
448
$ ret = (new Dispatcher ())
447
449
->setRequest ($ req )
448
450
->setEndpointList ([]) // No routes
Original file line number Diff line number Diff line change @@ -116,13 +116,13 @@ private function getEndpoint($setCallback = true): EndpointInterface
116
116
use Traits \Request \Get;
117
117
use Traits \Input \NoRequired;
118
118
use Traits \Input \NoOptional;
119
- function getUri (): string
119
+ public function getUri (): string
120
120
{
121
121
}
122
- function handleException (\Throwable $ e ): Message \ResponseInterface
122
+ public function handleException (\Throwable $ e ): Message \ResponseInterface
123
123
{
124
124
}
125
- function execute (SafeInput $ input ): Message \ResponseInterface
125
+ public function execute (SafeInput $ input ): Message \ResponseInterface
126
126
{
127
127
}
128
128
};
Original file line number Diff line number Diff line change @@ -25,13 +25,13 @@ public function testAuthenticate()
25
25
use Traits \Request \Get;
26
26
use Traits \Input \NoRequired;
27
27
use Traits \Input \NoOptional;
28
- function getUri (): string
28
+ public function getUri (): string
29
29
{
30
30
}
31
- function handleException (\Throwable $ e ): Message \ResponseInterface
31
+ public function handleException (\Throwable $ e ): Message \ResponseInterface
32
32
{
33
33
}
34
- function execute (SafeInput $ input ): Message \ResponseInterface
34
+ public function execute (SafeInput $ input ): Message \ResponseInterface
35
35
{
36
36
}
37
37
};
Original file line number Diff line number Diff line change @@ -50,9 +50,9 @@ public function testUris()
50
50
$ data = $ this ->uris ();
51
51
foreach ($ data as $ testCase ) {
52
52
list ($ uri , $ shouldMatch , $ matches ) = $ testCase ;
53
- $ this ->assertInternalType ( ' string ' , $ uri );
54
- $ this ->assertInternalType ( ' bool ' , $ shouldMatch );
55
- $ this ->assertInternalType ( ' array ' , $ matches );
53
+ $ this ->assertIsString ( $ uri );
54
+ $ this ->assertIsBool ( $ shouldMatch );
55
+ $ this ->assertIsArray ( $ matches );
56
56
}
57
57
}
58
58
You can’t perform that action at this time.
0 commit comments