assertArraySubset()
assertArraySubset(array $subset, array $array[, bool $strict = '', string $message = ''])
Reports an error identified by $message if $array does not contains the $subset.
$strict is a flag used to compare the identity of objects within arrays.
Example A.3: Usage of assertArraySubset()
<?php
use PHPUnit\Framework\TestCase;
class ArraySubsetTest extends TestCase
{
public function testFailure()
{
$this->assertArraySubset(['config' => ['key-a', 'key-b']], ['config' => ['key-a']]);
}
}
?>
phpunit ArrayHasKeyTest
PHPUnit 4.4.0 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 5.00Mb
There was 1 failure:
1) Epilog\EpilogTest::testNoFollowOption
Failed asserting that an array has the subset Array &0 (
'config' => Array &1 (
0 => 'key-a'
1 => 'key-b'
)
).
/home/sb/ArraySubsetTest.php:6
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
Please login to continue.