File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22All notable changes to this project will be documented in this file.
33
44The 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 )
58
69## [ 3.2.1] - 2018-10-24
710### Summary
Original file line number Diff line number Diff line change 11includes :
22 - vendor/phpstan/phpstan-phpunit/extension.neon
33
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 1717trait EndpointTestCases
1818{
1919 use HandlesOwnErrorsTestCases;
20+ use Testing \PHPUnit8Shim;
2021 use ValidationTestTrait;
2122
2223 /**
@@ -47,8 +48,7 @@ protected function getValidation(): ValidationInterface
4748 public function testGetUri (string $ uri , bool $ match , array $ expectedMatches )
4849 {
4950 $ endpoint = $ this ->getEndpoint ();
50- $ this ->assertInternalType (
51- 'string ' ,
51+ $ this ->assertIsString (
5252 $ endpoint ->getUri (),
5353 'getUri did not return a string '
5454 );
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 44
55namespace Firehed \API ;
66
7+ use BadMethodCallException ;
78use Exception ;
89use Firehed \API \Authentication ;
910use Firehed \API \Authorization ;
1011use Firehed \API \Interfaces \EndpointInterface ;
1112use Firehed \API \Errors \HandlerInterface ;
13+ use OutOfBoundsException ;
1214use Psr \Container \ContainerInterface ;
1315use Psr \Http \Message \RequestInterface ;
1416use Psr \Http \Message \ResponseInterface ;
@@ -425,24 +427,24 @@ public function testErrorInResponseHandler()
425427
426428 /**
427429 * @covers ::dispatch
428- * @expectedException BadMethodCallException
429- * @expectedExceptionCode 500
430430 */
431431 public function testDispatchThrowsWhenMissingData ()
432432 {
433433 $ d = new Dispatcher ();
434+ $ this ->expectException (BadMethodCallException::class);
435+ $ this ->expectExceptionCode (500 );
434436 $ ret = $ d ->dispatch ();
435437 }
436438
437439 /**
438440 * @covers ::dispatch
439- * @expectedException OutOfBoundsException
440- * @expectedExceptionCode 404
441441 */
442442 public function testNoRouteMatchReturns404 ()
443443 {
444444 $ req = $ this ->getMockRequestWithUriPath ('/ ' );
445445
446+ $ this ->expectException (OutOfBoundsException::class);
447+ $ this ->expectExceptionCode (404 );
446448 $ ret = (new Dispatcher ())
447449 ->setRequest ($ req )
448450 ->setEndpointList ([]) // No routes
Original file line number Diff line number Diff line change @@ -116,13 +116,13 @@ private function getEndpoint($setCallback = true): EndpointInterface
116116 use Traits \Request \Get;
117117 use Traits \Input \NoRequired;
118118 use Traits \Input \NoOptional;
119- function getUri (): string
119+ public function getUri (): string
120120 {
121121 }
122- function handleException (\Throwable $ e ): Message \ResponseInterface
122+ public function handleException (\Throwable $ e ): Message \ResponseInterface
123123 {
124124 }
125- function execute (SafeInput $ input ): Message \ResponseInterface
125+ public function execute (SafeInput $ input ): Message \ResponseInterface
126126 {
127127 }
128128 };
Original file line number Diff line number Diff line change @@ -25,13 +25,13 @@ public function testAuthenticate()
2525 use Traits \Request \Get;
2626 use Traits \Input \NoRequired;
2727 use Traits \Input \NoOptional;
28- function getUri (): string
28+ public function getUri (): string
2929 {
3030 }
31- function handleException (\Throwable $ e ): Message \ResponseInterface
31+ public function handleException (\Throwable $ e ): Message \ResponseInterface
3232 {
3333 }
34- function execute (SafeInput $ input ): Message \ResponseInterface
34+ public function execute (SafeInput $ input ): Message \ResponseInterface
3535 {
3636 }
3737 };
Original file line number Diff line number Diff line change @@ -50,9 +50,9 @@ public function testUris()
5050 $ data = $ this ->uris ();
5151 foreach ($ data as $ testCase ) {
5252 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 );
5656 }
5757 }
5858
You can’t perform that action at this time.
0 commit comments