test: use FakeReflector instead of anonymous class

This commit is contained in:
Romain Canon 2022-07-13 22:01:18 +02:00
parent b47a1bbb5d
commit 703ba55ada

View File

@ -6,6 +6,7 @@ namespace CuyZ\Valinor\Tests\Unit\Definition;
use CuyZ\Valinor\Definition\DoctrineAnnotations; use CuyZ\Valinor\Definition\DoctrineAnnotations;
use CuyZ\Valinor\Definition\Exception\InvalidReflectionParameter; use CuyZ\Valinor\Definition\Exception\InvalidReflectionParameter;
use CuyZ\Valinor\Tests\Fake\FakeReflector;
use CuyZ\Valinor\Tests\Fixture\Annotation\AnnotationWithArguments; use CuyZ\Valinor\Tests\Fixture\Annotation\AnnotationWithArguments;
use CuyZ\Valinor\Tests\Fixture\Annotation\BasicAnnotation; use CuyZ\Valinor\Tests\Fixture\Annotation\BasicAnnotation;
use CuyZ\Valinor\Tests\Fixture\Attribute\BasicAttribute; use CuyZ\Valinor\Tests\Fixture\Attribute\BasicAttribute;
@ -14,7 +15,6 @@ use ReflectionClass;
use ReflectionMethod; use ReflectionMethod;
use ReflectionParameter; use ReflectionParameter;
use ReflectionProperty; use ReflectionProperty;
use Reflector;
use function get_class; use function get_class;
use function iterator_to_array; use function iterator_to_array;
@ -121,17 +121,7 @@ final class DoctrineAnnotationsTest extends TestCase
public function test_invalid_reflection_throws_exception(): void public function test_invalid_reflection_throws_exception(): void
{ {
$wrongReflector = new class () implements Reflector { $wrongReflector = new FakeReflector();
public static function export(): string
{
return 'foo';
}
public function __toString(): string
{
return 'foo';
}
};
$this->expectException(InvalidReflectionParameter::class); $this->expectException(InvalidReflectionParameter::class);
$this->expectExceptionCode(1534263918); $this->expectExceptionCode(1534263918);