|
17 | 17 | use ApiPlatform\Core\DataPersister\DataPersisterInterface;
|
18 | 18 | use ApiPlatform\Core\EventListener\WriteListener;
|
19 | 19 | use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy;
|
| 20 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyTableInheritance; |
| 21 | +use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyTableInheritanceChild; |
20 | 22 | use PHPUnit\Framework\TestCase;
|
21 | 23 | use Symfony\Component\HttpFoundation\Request;
|
22 | 24 | use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
|
@@ -261,6 +263,30 @@ public function testOnKernelViewWithNoResourceClass()
|
261 | 263 | (new WriteListener($dataPersisterProphecy->reveal(), $iriConverterProphecy->reveal()))->onKernelView($event);
|
262 | 264 | }
|
263 | 265 |
|
| 266 | + public function testOnKernelViewWithParentResourceClass() |
| 267 | + { |
| 268 | + $dummy = new DummyTableInheritanceChild(); |
| 269 | + |
| 270 | + $dataPersisterProphecy = $this->prophesize(DataPersisterInterface::class); |
| 271 | + $dataPersisterProphecy->supports($dummy)->willReturn(true)->shouldBeCalled(); |
| 272 | + $dataPersisterProphecy->persist($dummy)->willReturn($dummy)->shouldBeCalled(); |
| 273 | + |
| 274 | + $iriConverterProphecy = $this->prophesize(IriConverterInterface::class); |
| 275 | + $iriConverterProphecy->getIriFromItem($dummy)->shouldNotBeCalled(); |
| 276 | + |
| 277 | + $request = new Request([], [], ['_api_resource_class' => DummyTableInheritance::class, '_api_item_operation_name' => 'put', '_api_persist' => true]); |
| 278 | + $request->setMethod('PUT'); |
| 279 | + |
| 280 | + $event = new GetResponseForControllerResultEvent( |
| 281 | + $this->prophesize(HttpKernelInterface::class)->reveal(), |
| 282 | + $request, |
| 283 | + HttpKernelInterface::MASTER_REQUEST, |
| 284 | + $dummy |
| 285 | + ); |
| 286 | + |
| 287 | + (new WriteListener($dataPersisterProphecy->reveal(), $iriConverterProphecy->reveal()))->onKernelView($event); |
| 288 | + } |
| 289 | + |
264 | 290 | public function testOnKernelViewWithNoDataPersisterSupport()
|
265 | 291 | {
|
266 | 292 | $dummy = new Dummy();
|
|
0 commit comments