/** * @test * @author Karsten Dambekalns <*****@*****.**> */ public function unregisterReconstitutedObjectRemovesObjectFromSession() { $someObject = new \ArrayObject(); $session = new \F3\FLOW3\Persistence\Session(); $session->registerReconstitutedObject($someObject); $session->unregisterReconstitutedObject($someObject); $reconstitutedObjects = $session->getReconstitutedObjects(); $this->assertFalse($reconstitutedObjects->contains($someObject)); }
/** * @test * @author Karsten Dambekalns <*****@*****.**> */ public function persistAllFetchesRemovedObjects() { $entity1 = new \F3\FLOW3\Tests\Persistence\Fixture\Model\CleanEntity(); $entity3 = new \F3\FLOW3\Tests\Persistence\Fixture\Model\CleanEntity(); $repository = $this->getMock($this->buildAccessibleProxy('F3\\FLOW3\\Persistence\\Repository'), array('dummy')); $repository->_set('objectType', get_class($entity1)); $repository->remove($entity1); $mockReflectionService = $this->getMock('F3\\FLOW3\\Reflection\\ReflectionService'); $mockReflectionService->expects($this->once())->method('getAllImplementationClassNamesForInterface')->with('F3\\FLOW3\\Persistence\\RepositoryInterface')->will($this->returnValue(array('F3\\FLOW3\\Persistence\\Repository'))); $mockObjectManager = $this->getMock('F3\\FLOW3\\Object\\ObjectManagerInterface'); $mockObjectManager->expects($this->once())->method('getObject')->with('F3\\FLOW3\\Persistence\\Repository')->will($this->returnValue($repository)); $session = new \F3\FLOW3\Persistence\Session(); $session->registerReconstitutedObject($entity1); $session->registerReconstitutedObject($entity3); $mockBackend = $this->getMock('F3\\FLOW3\\Persistence\\BackendInterface'); // this is the really important assertion! $deletedObjectStorage = new \SplObjectStorage(); $deletedObjectStorage->attach($entity1); $mockBackend->expects($this->once())->method('setDeletedEntities')->with($deletedObjectStorage); $manager = new \F3\FLOW3\Persistence\PersistenceManager(); $manager->injectBackend($mockBackend); $manager->injectReflectionService($mockReflectionService); $manager->injectPersistenceSession($session); $manager->injectObjectManager($mockObjectManager); $manager->persistAll(); $this->assertTrue($session->getReconstitutedObjects()->contains($entity3)); }