diff --git a/src/Component/spec/Reflection/CallableReflectionSpec.php b/src/Component/spec/Reflection/CallableReflectionSpec.php deleted file mode 100644 index fd8dbc3f4..000000000 --- a/src/Component/spec/Reflection/CallableReflectionSpec.php +++ /dev/null @@ -1,46 +0,0 @@ -shouldHaveType(CallableReflection::class); - } - - function it_reflects_an_array_callable(): void - { - $this::from([RepositoryWithCallables::class, 'find'])->shouldHaveType(\ReflectionFunctionAbstract::class); - } - - function it_reflects_a_closure_callable(): void - { - $this::from(fn (): array => [])->shouldHaveType(\ReflectionFunctionAbstract::class); - } - - function it_reflects_a_string_callable(): void - { - $this::from('Sylius\Component\Resource\Tests\Dummy\RepositoryWithCallables::find')->shouldHaveType(\ReflectionFunctionAbstract::class); - } - - function it_reflects_an_invokable_callable(): void - { - $this::from(new RepositoryWithCallables())->shouldHaveType(\ReflectionFunctionAbstract::class); - } -} diff --git a/src/Component/tests/Reflection/CallableReflectionTest.php b/src/Component/tests/Reflection/CallableReflectionTest.php new file mode 100644 index 000000000..550f09ad0 --- /dev/null +++ b/src/Component/tests/Reflection/CallableReflectionTest.php @@ -0,0 +1,52 @@ +assertInstanceOf(CallableReflection::class, $callableReflection); + } + + public function testItReflectsAnArrayCallable(): void + { + $reflection = CallableReflection::from([RepositoryWithCallables::class, 'find']); + $this->assertInstanceOf(ReflectionFunctionAbstract::class, $reflection); + } + + public function testItReflectsAClosureCallable(): void + { + $reflection = CallableReflection::from(fn (): array => []); + $this->assertInstanceOf(ReflectionFunctionAbstract::class, $reflection); + } + + public function testItReflectsAStringCallable(): void + { + $reflection = CallableReflection::from('Sylius\Component\Resource\Tests\Dummy\RepositoryWithCallables::find'); + $this->assertInstanceOf(ReflectionFunctionAbstract::class, $reflection); + } + + public function testItReflectsAnInvokableCallable(): void + { + $reflection = CallableReflection::from(new RepositoryWithCallables()); + $this->assertInstanceOf(ReflectionFunctionAbstract::class, $reflection); + } +} diff --git a/src/Component/spec/Reflection/Filter/FunctionArgumentsFilterSpec.php b/src/Component/tests/Reflection/Filter/FunctionArgumentsFilterTest.php similarity index 51% rename from src/Component/spec/Reflection/Filter/FunctionArgumentsFilterSpec.php rename to src/Component/tests/Reflection/Filter/FunctionArgumentsFilterTest.php index 162a450fb..e52b13109 100644 --- a/src/Component/spec/Reflection/Filter/FunctionArgumentsFilterSpec.php +++ b/src/Component/tests/Reflection/Filter/FunctionArgumentsFilterTest.php @@ -11,33 +11,40 @@ declare(strict_types=1); -namespace spec\Sylius\Resource\Reflection\Filter; +namespace Sylius\Resource\Tests\Reflection\Filter; -use PhpSpec\ObjectBehavior; +use PHPUnit\Framework\TestCase; use Sylius\Component\Resource\Tests\Dummy\RepositoryWithCallables; use Sylius\Resource\Reflection\CallableReflection; use Sylius\Resource\Reflection\Filter\FunctionArgumentsFilter; -final class FunctionArgumentsFilterSpec extends ObjectBehavior +final class FunctionArgumentsFilterTest extends TestCase { - function it_is_initializable(): void + private FunctionArgumentsFilter $functionArgumentsFilter; + + protected function setUp(): void { - $this->shouldHaveType(FunctionArgumentsFilter::class); + $this->functionArgumentsFilter = new FunctionArgumentsFilter(); } - function it_filters_matching_arguments(): void + public function testItIsInitializable(): void + { + $this->assertInstanceOf(FunctionArgumentsFilter::class, $this->functionArgumentsFilter); + } + + public function testItFiltersMatchingArguments(): void { $callable = [RepositoryWithCallables::class, 'find']; $reflector = CallableReflection::from($callable); - $this->filter( + $result = $this->functionArgumentsFilter->filter( $reflector, [ 'id' => 'my_id', 'foo' => 'fighters', ], - )->shouldReturn([ - 'id' => 'my_id', - ]); + ); + + $this->assertSame(['id' => 'my_id'], $result); } }