| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Base TestCase which ensures that PHPUnit does not print warnings because of deprecated methods |
| 5 |
* |
| 6 |
* @license MIT |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace WebPConvert\Tests; |
| 10 |
|
| 11 |
use PHPUnit\Framework\TestCase; |
| 12 |
// use PHPUnit\Runner\Version as PHPUnitVersion; // no - breaks our PHP 5.6 travis test |
| 13 |
|
| 14 |
class CompatibleTestCase extends TestCase |
| 15 |
{ |
| 16 |
|
| 17 |
// By the way: |
| 18 |
// Just discovered that its possible to easily skip tests with an annotation |
| 19 |
// based on criterias such as PHPUnit version or extention. |
| 20 |
// See: https://phpunit.de/manual/3.7/en/incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.skipping-tests-using-requires |
| 21 |
// (and https://stackoverflow.com/questions/4837748/how-to-detect-version-of-phpunit) |
| 22 |
|
| 23 |
|
| 24 |
public function assertDoesNotMatchRegularExpression2($arg1, $arg2) |
| 25 |
{ |
| 26 |
// https://stackoverflow.com/questions/4837748/how-to-detect-version-of-phpunit |
| 27 |
/* |
| 28 |
$phpUnitVersion = PHPUnitVersion::id(); |
| 29 |
$phpUnitMajorVersion = explode('.', $phpUnitVersion)[0]; |
| 30 |
$phpUnitMinorVersion = explode('.', $phpUnitVersion)[1]; |
| 31 |
|
| 32 |
$phpUnit91OrNewer = (($phpUnitMajorVersion >=9) && ($phpUnitMinorVersion >=1)); |
| 33 |
*/ |
| 34 |
|
| 35 |
if (method_exists(TestCase::class, 'assertDoesNotMatchRegularExpression')) { |
| 36 |
$this->assertDoesNotMatchRegularExpression($arg1, $arg2); |
| 37 |
} else { |
| 38 |
$this->assertNotRegExp($arg1, $arg2); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
public function assertMatchesRegularExpression2($arg1, $arg2) |
| 43 |
{ |
| 44 |
// https://stackoverflow.com/questions/4837748/how-to-detect-version-of-phpunit |
| 45 |
|
| 46 |
if (method_exists(TestCase::class, 'assertMatchesRegularExpression')) { |
| 47 |
$this->assertMatchesRegularExpression($arg1, $arg2); |
| 48 |
} else { |
| 49 |
$this->assertRegExp($arg1, $arg2); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
} |
| 54 |
|