Assert.php
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Illuminate\Foundation\Testing;
use ArrayAccess;
use PHPUnit\Util\InvalidArgumentHelper;
use PHPUnit\Framework\Assert as PHPUnit;
use PHPUnit\Framework\Constraint\ArraySubset;
/**
* @internal This class is not meant to be used or overwritten outside the framework itself.
*/
abstract class Assert extends PHPUnit
{
/**
* Asserts that an array has a specified subset.
*
* This method was taken over from PHPUnit where it was deprecated. See link for more info.
*
* @param array|\ArrayAccess $subset
* @param array|\ArrayAccess $array
* @param bool $checkForObjectIdentity
* @param string $message
* @return void
*
* @link https://github.com/sebastianbergmann/phpunit/issues/3494
*/
public static function assertArraySubset($subset, $array, bool $checkForObjectIdentity = false, string $message = ''): void
{
if (! (is_array($subset) || $subset instanceof ArrayAccess)) {
throw InvalidArgumentHelper::factory(1, 'array or ArrayAccess');
}
if (! (is_array($array) || $array instanceof ArrayAccess)) {
throw InvalidArgumentHelper::factory(2, 'array or ArrayAccess');
}
$constraint = new ArraySubset($subset, $checkForObjectIdentity);
static::assertThat($array, $constraint, $message);
}
}