-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
121 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
includes: | ||
- vendor/phpstan/phpstan-phpunit/extension.neon | ||
|
||
parameters: | ||
ignoreErrors: | ||
- '#Call to an undefined static method PHPUnit\\Framework\\TestCase::assertIs(Array|Bool|String)\(\)#' | ||
reportUnmatchedIgnoredErrors: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Firehed\API\Traits\Testing; | ||
|
||
/** | ||
* phpcs:disable | ||
* | ||
* Implement some horrible hacks to allow PHP7.0 users to use assertIsString | ||
* which natively has a void return type. | ||
* | ||
* @internal | ||
*/ | ||
if (version_compare(PHP_VERSION, '7.1.0', '>=')) { | ||
trait PHPUnit8Shim | ||
{ | ||
use PHPUnit8ShimPHPGTE71; | ||
} | ||
} else { | ||
trait PHPUnit8Shim | ||
{ | ||
use PHPUnit8ShimPHPLT71; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Firehed\API\Traits\Testing; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Create assertIsFoo static methods introduced in PHPUnit 7.5 for users with | ||
* earlier versions | ||
* | ||
* @internal | ||
*/ | ||
trait PHPUnit8ShimPHPGTE71 | ||
{ | ||
public static function assertIsArray($actual, string $message = ''): void | ||
{ | ||
if (method_exists(TestCase::class, 'assertIsArray')) { | ||
TestCase::assertIsArray($actual, $message); | ||
} else { | ||
TestCase::assertInternalType('array', $actual, $message); | ||
} | ||
} | ||
|
||
public static function assertIsBool($actual, string $message = ''): void | ||
{ | ||
if (method_exists(TestCase::class, 'assertIsBool')) { | ||
TestCase::assertIsBool($actual, $message); | ||
} else { | ||
TestCase::assertInternalType('bool', $actual, $message); | ||
} | ||
} | ||
|
||
public static function assertIsString($actual, string $message = ''): void | ||
{ | ||
if (method_exists(TestCase::class, 'assertIsString')) { | ||
TestCase::assertIsString($actual, $message); | ||
} else { | ||
TestCase::assertInternalType('string', $actual, $message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Firehed\API\Traits\Testing; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* PHP 7.0-compatible shim (stripped return types) | ||
* Simply wraps assertInternalType since PHPUnit 7.5 (where the new versions | ||
* became available) requires 7.1 or later. | ||
* | ||
* @internal | ||
*/ | ||
trait PHPUnit8ShimPHPLT71 | ||
{ | ||
public static function assertIsArray($actual, string $message = '') | ||
{ | ||
TestCase::assertInternalType('array', $actual, $message); | ||
} | ||
|
||
public static function assertIsBool($actual, string $message = '') | ||
{ | ||
TestCase::assertInternalType('bool', $actual, $message); | ||
} | ||
|
||
public static function assertIsString($actual, string $message = '') | ||
{ | ||
TestCase::assertInternalType('string', $actual, $message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters