123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- declare(strict_types=1);
- /**
- * This file is part of Hyperf.
- *
- * @link https://www.hyperf.io
- * @document https://hyperf.wiki
- * @contact group@hyperf.io
- * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
- */
- namespace Hyperf\Testing;
- use ArrayAccess;
- use Hyperf\Testing\Constraint\ArraySubset;
- use Hyperf\Testing\Exception\InvalidArgumentException;
- use PHPUnit\Framework\Assert as PHPUnit;
- /**
- * @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.
- *
- * @param array|ArrayAccess $subset
- * @param array|ArrayAccess $array
- */
- public static function assertArraySubset($subset, $array, bool $checkForIdentity = false, string $msg = ''): void
- {
- if (! (is_array($subset) || $subset instanceof ArrayAccess)) { /* @phpstan-ignore-line */
- throw InvalidArgumentException::create(1, 'array or ArrayAccess');
- }
- if (! (is_array($array) || $array instanceof ArrayAccess)) { /* @phpstan-ignore-line */
- throw InvalidArgumentException::create(2, 'array or ArrayAccess');
- }
- $constraint = new ArraySubset($subset, $checkForIdentity);
- PHPUnit::assertThat($array, $constraint, $msg);
- }
- }
|