mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 12:29:43 +01:00
Fix prophecy mocking arg
This commit is contained in:
parent
3f7bc95129
commit
147b51b4c9
@ -8,6 +8,7 @@ use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
@ -22,7 +23,7 @@ use Rector\Doctrine\Contract\Mapper\DoctrineEntityAndRepositoryMapperInterface;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
||||
/**
|
||||
* @see \Rector\Core\Tests\Rector\Architecture\DoctrineRepositoryAsService\DoctrineRepositoryAsServiceTest
|
||||
* @see \Rector\Architecture\Tests\Rector\DoctrineRepositoryAsService\DoctrineRepositoryAsServiceTest
|
||||
*/
|
||||
final class ServiceLocatorToDIRector extends AbstractRector
|
||||
{
|
||||
@ -103,6 +104,12 @@ PHP
|
||||
return null;
|
||||
}
|
||||
|
||||
$firstArgumentValue = $node->args[0]->value;
|
||||
// possible mocking → skip
|
||||
if ($firstArgumentValue instanceof StaticCall) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var string|null $className */
|
||||
$className = $node->getAttribute(AttributeKey::CLASS_NAME);
|
||||
if ($className === null) {
|
||||
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Architecture\Tests\Rector\DoctrineRepositoryAsService\Fixture;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
|
||||
final class ItemRepositoryTest extends TestCase
|
||||
{
|
||||
public function testGetThrowsExceptionIfNotFound(): void
|
||||
{
|
||||
$entityManagerMock = $this->prophesize(EntityManagerInterface::class);
|
||||
|
||||
$entityManagerMock->getRepository(Argument::any());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user