diff --git a/composer.json b/composer.json index 57da5a9ab33..fb3bc51b31e 100644 --- a/composer.json +++ b/composer.json @@ -113,10 +113,7 @@ "autoload-dev": { "psr-4": { "ApiPlatform\\Core\\Tests\\": "tests/" - }, - "classmap": [ - "vendor/phpunit/phpunit/tests/" - ] + } }, "extra": { "branch-alias": { diff --git a/tests/Bridge/Symfony/Bundle/Test/Constraint/ArraySubsetTest.php b/tests/Bridge/Symfony/Bundle/Test/Constraint/ArraySubsetTest.php index a88914d74f7..955cdb78594 100644 --- a/tests/Bridge/Symfony/Bundle/Test/Constraint/ArraySubsetTest.php +++ b/tests/Bridge/Symfony/Bundle/Test/Constraint/ArraySubsetTest.php @@ -14,17 +14,12 @@ namespace ApiPlatform\Core\Tests\Bridge\Symfony\Bundle\Test\Constraint; use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Constraint\ArraySubset; -use ArrayAccessible; -use ArrayObject; -use Countable; +use ApiPlatform\Core\Tests\Fixtures\ArrayAccessible; use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\SelfDescribing; use PHPUnit\Framework\TestCase; use PHPUnit\Runner\Version; -use ReflectionClass; use SebastianBergmann\RecursionContext\InvalidArgumentException; -use Traversable; -use function sprintf; /** * Imported from dms/phpunit-arraysubset-asserts, because the original constraint has been deprecated. @@ -64,12 +59,12 @@ public static function evaluateDataProvider(): array 'loose array subset and ArrayObject other' => [ 'expected' => true, 'subset' => ['bar' => 0], - 'other' => new ArrayObject(['foo' => '', 'bar' => '0']), + 'other' => new \ArrayObject(['foo' => '', 'bar' => '0']), 'strict' => false, ], 'strict ArrayObject subset and array other' => [ 'expected' => true, - 'subset' => new ArrayObject(['bar' => 0]), + 'subset' => new \ArrayObject(['bar' => 0]), 'other' => ['foo' => '', 'bar' => 0], 'strict' => true, ], @@ -77,9 +72,9 @@ public static function evaluateDataProvider(): array } /** - * @param array|Traversable|mixed[] $subset - * @param array|Traversable|mixed[] $other - * @param bool $strict + * @param array|\Traversable|mixed[] $subset + * @param array|\Traversable|mixed[] $other + * @param bool $strict * * @throws ExpectationFailedException * @throws InvalidArgumentException @@ -118,20 +113,20 @@ public function testEvaluateFailMessage(): void public function testIsCountable(): void { - $reflection = new ReflectionClass(ArraySubset::class); + $reflection = new \ReflectionClass(ArraySubset::class); $this->assertTrue( - $reflection->implementsInterface(Countable::class), + $reflection->implementsInterface(\Countable::class), sprintf( 'Failed to assert that ArraySubset implements "%s".', - Countable::class + \Countable::class ) ); } public function testIsSelfDescribing(): void { - $reflection = new ReflectionClass(ArraySubset::class); + $reflection = new \ReflectionClass(ArraySubset::class); $this->assertTrue( $reflection->implementsInterface(SelfDescribing::class), diff --git a/tests/Fixtures/ArrayAccessible.php b/tests/Fixtures/ArrayAccessible.php new file mode 100644 index 00000000000..92073f5d942 --- /dev/null +++ b/tests/Fixtures/ArrayAccessible.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Core\Tests\Fixtures; + +class ArrayAccessible implements \ArrayAccess, \IteratorAggregate +{ + private $array; + + public function __construct(array $array = []) + { + $this->array = $array; + } + + public function offsetExists($offset) + { + return \array_key_exists($offset, $this->array); + } + + public function offsetGet($offset) + { + return $this->array[$offset]; + } + + public function offsetSet($offset, $value): void + { + if (null === $offset) { + $this->array[] = $value; + } else { + $this->array[$offset] = $value; + } + } + + public function offsetUnset($offset): void + { + unset($this->array[$offset]); + } + + public function getIterator() + { + return new \ArrayIterator($this->array); + } +}