public function testOnKernelViewWithControllerResultAndPostMethod() { $dummy = new Dummy(); $dummy->setName('Dummyrino'); $objectManagerProphecy = $this->prophesize(ObjectManager::class); $objectManagerProphecy->persist($dummy)->shouldBeCalled(); $objectManagerProphecy->flush()->shouldBeCalled(); $managerRegistryProphecy = $this->prophesize(ManagerRegistry::class); $managerRegistryProphecy->getManagerForClass('Dummy')->willReturn($objectManagerProphecy->reveal()); $writeListener = new WriteListener($managerRegistryProphecy->reveal()); $httpKernelProphecy = $this->prophesize(HttpKernelInterface::class); $request = new Request(); $request->setMethod(Request::METHOD_POST); $request->attributes->set('_api_resource_class', 'Dummy'); $event = new GetResponseForControllerResultEvent($httpKernelProphecy->reveal(), $request, HttpKernelInterface::MASTER_REQUEST, $dummy); $this->assertNull($writeListener->onKernelView($event)); $this->assertNotEquals($dummy, $writeListener->onKernelView($event)); }