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:
parent
2eb08ce673
commit
0822537f0e
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ composer.lock
|
|||||||
.idea
|
.idea
|
||||||
tests-clover.xml
|
tests-clover.xml
|
||||||
tests-junit.xml
|
tests-junit.xml
|
||||||
|
.phpunit.result.cache
|
||||||
|
@ -12,6 +12,6 @@
|
|||||||
</filter>
|
</filter>
|
||||||
<logging>
|
<logging>
|
||||||
<log type="coverage-clover" target="tests-clover.xml"/>
|
<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>
|
</logging>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
@ -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' );
|
$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 ) ) );
|
$result = invoke_static( StatifyBlacklist_Admin::class, 'sanitizeIPs', array( array_merge( $valid, $invalid ) ) );
|
||||||
$this->assertNotFalse( $result );
|
$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 );
|
$this->assertEquals( $valid, $result );
|
||||||
|
|
||||||
// IPv6 tests.
|
// 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 ) ) );
|
$result = invoke_static( StatifyBlacklist_Admin::class, 'sanitizeIPs', array( array_merge( $valid, $invalid ) ) );
|
||||||
$this->assertNotFalse( $result );
|
$this->assertNotFalse( $result );
|
||||||
$this->assertInternalType( 'array', $result );
|
if ( method_exists( $this, 'assertIsArray' ) ) {
|
||||||
|
$this->assertIsArray( $result );
|
||||||
|
} else {
|
||||||
|
$this->assertInternalType( 'array', $result );
|
||||||
|
}
|
||||||
$this->assertEquals( $valid, $result );
|
$this->assertEquals( $valid, $result );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user