/** * @test */ public function modificationsOnRetrievedEntitiesArePersistedIfUpdateHasBeenCalled() { $this->postRepository = $this->objectManager->get('TYPO3\\FLOW3\\Tests\\Functional\\Persistence\\Fixtures\\PostRepository'); $post = new Post(); $post->setTitle('Sample'); $this->postRepository->add($post); $this->persistenceManager->persistAll(); $post = $this->postRepository->findOneByTitle('Sample'); $post->setTitle('Modified Sample'); $this->postRepository->update($post); $this->persistenceManager->persistAll(); $post = $this->postRepository->findOneByTitle('Modified Sample'); $this->assertNotNull($post); $this->assertEquals('Modified Sample', $post->getTitle()); }
/** * @test */ public function entitiesWithOwnRepositoryAreNotRemovedIfRelatedRootEntityIsRemoved() { $comment = new Comment(); $this->commentRepository->add($comment); $post = new Post(); $post->setComment($comment); $this->postRepository->add($post); $this->persistenceManager->persistAll(); $commentIdentifier = $this->persistenceManager->getIdentifierByObject($comment); $retrievedComment = $this->persistenceManager->getObjectByIdentifier($commentIdentifier, 'TYPO3\\FLOW3\\Tests\\Functional\\Persistence\\Fixtures\\Comment'); $this->assertSame($comment, $retrievedComment); $this->postRepository->remove($post); $this->persistenceManager->persistAll(); $retrievedComment = $this->persistenceManager->getObjectByIdentifier($commentIdentifier, 'TYPO3\\FLOW3\\Tests\\Functional\\Persistence\\Fixtures\\Comment'); $this->assertSame($comment, $retrievedComment); }