Skip to content

Commit eb4830c

Browse files
authored
Merge pull request #976 from soyuka/fix-phpunit
Fix private service deprecation in SearchFilterTest
2 parents 29b37f2 + bfeb9ed commit eb4830c

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/Bridge/Doctrine/Orm/Filter/SearchFilterTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
use ApiPlatform\Core\Api\IriConverterInterface;
1515
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
1616
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGenerator;
17+
use ApiPlatform\Core\Exception\InvalidArgumentException;
1718
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy;
19+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedDummy;
1820
use Doctrine\Common\Persistence\ManagerRegistry;
1921
use Doctrine\ORM\EntityRepository;
22+
use Prophecy\Argument;
2023
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
2124
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2225
use Symfony\Component\HttpFoundation\Request;
@@ -62,7 +65,23 @@ protected function setUp()
6265
self::bootKernel();
6366
$manager = DoctrineTestHelper::createTestEntityManager();
6467
$this->managerRegistry = self::$kernel->getContainer()->get('doctrine');
65-
$this->iriConverter = self::$kernel->getContainer()->get('api_platform.iri_converter');
68+
69+
$relatedDummyProphecy = $this->prophesize(RelatedDummy::class);
70+
71+
$iriConverterProphecy = $this->prophesize(IriConverterInterface::class);
72+
73+
$iriConverterProphecy->getItemFromIri(Argument::type('string'), ['fetch_data' => false])->will(function ($args) use ($relatedDummyProphecy) {
74+
if (false !== strpos($args[0], '/related_dummies')) {
75+
$relatedDummyProphecy->getId()->shouldBeCalled()->willReturn(1);
76+
77+
return $relatedDummyProphecy->reveal();
78+
}
79+
80+
throw new InvalidArgumentException();
81+
});
82+
83+
$this->iriConverter = $iriConverterProphecy->reveal();
84+
6685
$this->propertyAccessor = self::$kernel->getContainer()->get('property_accessor');
6786
$this->repository = $manager->getRepository(Dummy::class);
6887
$this->resourceClass = Dummy::class;

0 commit comments

Comments
 (0)