Arguments:
array|object $expectedmixed $actualstring $message = ''bool $strict = truebool $allowNull = false
Checks if $actual contains values as described in $expected.
Unlike assertSame() and assertEquals() $actual can contain other fields which are not important in this test.
$expected = [
'first_name' => 'John',
'last_name' => 'Tester',
];
$actual = [
'first_name' => 'John',
'last_name' => 'Tester',
'email' => 'john@example.com',
'age' => 25,
];
$this->assertPartiallySame($expected, $actual); // we check only important fields for us$actualand$expectedare compared as arrays. These can be objects but will be cast to arrays.- If
$actualis not array or object it leads to fail. - If arrays are associative order of keys is not important.
$strict = false- allows compareintwithstringandintwithbool.$allowNumm = true- if a key is missing in$actualit is equivalent toNULL.