diff --git a/src/Component/spec/Reflection/CallableReflectionSpec.php b/src/Component/spec/Reflection/CallableReflectionSpec.php index fd8dbc3f4..550f09ad0 100644 --- a/src/Component/spec/Reflection/CallableReflectionSpec.php +++ b/src/Component/spec/Reflection/CallableReflectionSpec.php @@ -11,36 +11,42 @@ declare(strict_types=1); -namespace spec\Sylius\Resource\Reflection; +namespace Sylius\Resource\Tests\Reflection; -use PhpSpec\ObjectBehavior; +use PHPUnit\Framework\TestCase; +use ReflectionFunctionAbstract; use Sylius\Component\Resource\Tests\Dummy\RepositoryWithCallables; use Sylius\Resource\Reflection\CallableReflection; -class CallableReflectionSpec extends ObjectBehavior +final class CallableReflectionTest extends TestCase { - function it_is_initializable(): void + public function testItIsInitializable(): void { - $this->shouldHaveType(CallableReflection::class); + $callableReflection = new CallableReflection(); + $this->assertInstanceOf(CallableReflection::class, $callableReflection); } - function it_reflects_an_array_callable(): void + public function testItReflectsAnArrayCallable(): void { - $this::from([RepositoryWithCallables::class, 'find'])->shouldHaveType(\ReflectionFunctionAbstract::class); + $reflection = CallableReflection::from([RepositoryWithCallables::class, 'find']); + $this->assertInstanceOf(ReflectionFunctionAbstract::class, $reflection); } - function it_reflects_a_closure_callable(): void + public function testItReflectsAClosureCallable(): void { - $this::from(fn (): array => [])->shouldHaveType(\ReflectionFunctionAbstract::class); + $reflection = CallableReflection::from(fn (): array => []); + $this->assertInstanceOf(ReflectionFunctionAbstract::class, $reflection); } - function it_reflects_a_string_callable(): void + public function testItReflectsAStringCallable(): void { - $this::from('Sylius\Component\Resource\Tests\Dummy\RepositoryWithCallables::find')->shouldHaveType(\ReflectionFunctionAbstract::class); + $reflection = CallableReflection::from('Sylius\Component\Resource\Tests\Dummy\RepositoryWithCallables::find'); + $this->assertInstanceOf(ReflectionFunctionAbstract::class, $reflection); } - function it_reflects_an_invokable_callable(): void + public function testItReflectsAnInvokableCallable(): void { - $this::from(new RepositoryWithCallables())->shouldHaveType(\ReflectionFunctionAbstract::class); + $reflection = CallableReflection::from(new RepositoryWithCallables()); + $this->assertInstanceOf(ReflectionFunctionAbstract::class, $reflection); } } diff --git a/src/Component/spec/Reflection/Filter/FunctionArgumentsFilterSpec.php b/src/Component/spec/Reflection/Filter/FunctionArgumentsFilterSpec.php index 162a450fb..e52b13109 100644 --- a/src/Component/spec/Reflection/Filter/FunctionArgumentsFilterSpec.php +++ b/src/Component/spec/Reflection/Filter/FunctionArgumentsFilterSpec.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); } }