Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[phpspec-2-phpunit] migration of tests (Reflection) #937

Open
wants to merge 2 commits into
base: 1.12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions src/Component/spec/Reflection/CallableReflectionSpec.php

This file was deleted.

52 changes: 52 additions & 0 deletions src/Component/tests/Reflection/CallableReflectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Resource\Tests\Reflection;

use PHPUnit\Framework\TestCase;
use ReflectionFunctionAbstract;
use Sylius\Component\Resource\Tests\Dummy\RepositoryWithCallables;
use Sylius\Resource\Reflection\CallableReflection;

final class CallableReflectionTest extends TestCase
{
public function testItIsInitializable(): void
{
$callableReflection = new CallableReflection();
$this->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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading