adjustments for PHPUnit 8

Added result cache to .gitignore and replaced assertInternalType() by
assertIsArray() with backwords compatibility for PHP 5 builds.
This commit is contained in:
Stefan Kalscheuer 2019-03-12 17:57:26 +01:00
parent 2eb08ce673
commit 0822537f0e
3 changed files with 17 additions and 4 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@ composer.lock
/dist/
.idea
tests-clover.xml
tests-junit.xml
tests-junit.xml
.phpunit.result.cache

View File

@ -12,6 +12,6 @@
</filter>
<logging>
<log type="coverage-clover" target="tests-clover.xml"/>
<log type="junit" target="tests-junit.xml" logIncompleteSkipped="false"/>
<log type="junit" target="tests-junit.xml"/>
</logging>
</phpunit>

View File

@ -320,7 +320,15 @@ class StatifyBlacklist_Test extends PHPUnit\Framework\TestCase {
$invalid = array( '12.34.56.789', '192.0.2.123/33', '192.0.2.123/-1' );
$result = invoke_static( StatifyBlacklist_Admin::class, 'sanitizeIPs', array( array_merge( $valid, $invalid ) ) );
$this->assertNotFalse( $result );
$this->assertInternalType( 'array', $result );
/*
* Unfortunately this is nencessary as long as we run PHP 5 tests, because "assertInternalType" is deprecated
* as of PHPUnit 8, but "assertIsArray" has been introduces in PHPUnit 7.5 which requires PHP >= 7.1.
*/
if ( method_exists( $this, 'assertIsArray' ) ) {
$this->assertIsArray( $result );
} else {
$this->assertInternalType( 'array', $result );
}
$this->assertEquals( $valid, $result );
// IPv6 tests.
@ -339,7 +347,11 @@ class StatifyBlacklist_Test extends PHPUnit\Framework\TestCase {
);
$result = invoke_static( StatifyBlacklist_Admin::class, 'sanitizeIPs', array( array_merge( $valid, $invalid ) ) );
$this->assertNotFalse( $result );
$this->assertInternalType( 'array', $result );
if ( method_exists( $this, 'assertIsArray' ) ) {
$this->assertIsArray( $result );
} else {
$this->assertInternalType( 'array', $result );
}
$this->assertEquals( $valid, $result );
}