|
14 | 14 | use ApiPlatform\Core\Api\IriConverterInterface;
|
15 | 15 | use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
|
16 | 16 | use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGenerator;
|
| 17 | +use ApiPlatform\Core\Exception\InvalidArgumentException; |
17 | 18 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy;
|
| 19 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\RelatedDummy; |
18 | 20 | use Doctrine\Common\Persistence\ManagerRegistry;
|
19 | 21 | use Doctrine\ORM\EntityRepository;
|
| 22 | +use Prophecy\Argument; |
20 | 23 | use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
21 | 24 | use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
22 | 25 | use Symfony\Component\HttpFoundation\Request;
|
@@ -62,7 +65,23 @@ protected function setUp()
|
62 | 65 | self::bootKernel();
|
63 | 66 | $manager = DoctrineTestHelper::createTestEntityManager();
|
64 | 67 | $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 | + |
66 | 85 | $this->propertyAccessor = self::$kernel->getContainer()->get('property_accessor');
|
67 | 86 | $this->repository = $manager->getRepository(Dummy::class);
|
68 | 87 | $this->resourceClass = Dummy::class;
|
|
0 commit comments