/** * @test */ public function entitiesWithOwnRepositoryAreNotRemovedIfRelatedRootEntityIsRemoved() { $comment = new Fixtures\Comment(); $this->commentRepository->add($comment); $post = new Fixtures\Post(); $post->setComment($comment); $this->postRepository->add($post); $this->persistenceManager->persistAll(); $commentIdentifier = $this->persistenceManager->getIdentifierByObject($comment); $retrievedComment = $this->persistenceManager->getObjectByIdentifier($commentIdentifier, Fixtures\Comment::class); $this->assertSame($comment, $retrievedComment); $this->postRepository->remove($post); $this->persistenceManager->persistAll(); $retrievedComment = $this->persistenceManager->getObjectByIdentifier($commentIdentifier, Fixtures\Comment::class); $this->assertSame($comment, $retrievedComment); }
/** * @test */ public function comlexQueryWithJoinsCanBeExecutedAfterDeserialization() { $postEntityRepository = new Fixtures\PostRepository(); $postEntityRepository->removeAll(); $commentRepository = new Fixtures\CommentRepository(); $commentRepository->removeAll(); $testEntity1 = new Fixtures\Post(); $testEntity1->setTitle('Flow'); $postEntityRepository->add($testEntity1); $testEntity2 = new Fixtures\Post(); $testEntity2->setTitle('Flow with comment'); $comment = new Fixtures\Comment(); $comment->setContent('Flow'); $testEntity2->setComment($comment); $postEntityRepository->add($testEntity2); $commentRepository->add($comment); $this->persistenceManager->persistAll(); $query = new Query(Fixtures\Post::class); $query->matching($query->equals('comment.content', 'Flow')); $serializedQuery = serialize($query); $unserializedQuery = unserialize($serializedQuery); $this->assertEquals(1, $unserializedQuery->execute()->count()); $this->assertEquals([$testEntity2], $unserializedQuery->execute()->toArray()); }