diff --git a/tests/Dao/CommentDaoTest.php b/tests/Dao/CommentDaoTest.php index 75da8e2d..f438d870 100644 --- a/tests/Dao/CommentDaoTest.php +++ b/tests/Dao/CommentDaoTest.php @@ -77,19 +77,34 @@ final class CommentDaoTest extends AbstractDatabaseTestCase $post = $postDao->findById($post->getId()); $this->assertNotNull($post); $this->assertEquals(1, $post->getCommentCount()); - - return [$postDao, $commentDao, $post, $comment]; } - /** - * @depends testPostMetadataSyncInsert - */ - public function testPostMetadataSyncDelete($args) + public function testPostMetadataSyncDelete() { - list ($postDao, $commentDao, $post, $comment) = $args; + $userDao = Injector::get(UserDao::class); + $postDao = Injector::get(PostDao::class); + $commentDao = Injector::get(CommentDao::class); + + $user = self::getTestUser('olivia'); + $userDao->save($user); + + $post = self::getTestPost(); + $postDao->save($post); + + $this->assertEquals(0, $post->getCommentCount()); + $this->assertNotNull($post->getId()); + + $comment = new Comment(); + $comment->setUser($user); + $comment->setPost($post); + $comment->setCreationTime(date('c')); + $comment->setLastEditTime(date('c')); + $comment->setText('whatever'); + $commentDao->save($comment); $commentDao->deleteById($comment->getId()); + $this->assertNotNull($post->getId()); $post = $postDao->findById($post->getId()); $this->assertNotNull($post); $this->assertEquals(0, $post->getCommentCount()); diff --git a/tests/Dao/TransactionManagerTest.php b/tests/Dao/TransactionManagerTest.php index d1d4d6e7..3356ae78 100644 --- a/tests/Dao/TransactionManagerTest.php +++ b/tests/Dao/TransactionManagerTest.php @@ -38,6 +38,9 @@ final class TransactionManagerTest extends AbstractDatabaseTestCase //ids that could be forged in transaction get left behind after rollback $this->assertNotNull($testEntity->getId()); + $this->databaseConnection->getPDO()->rollBack(); + $this->databaseConnection->getPDO()->beginTransaction(); + //but entities shouldn't be saved to database $this->assertNull($testDao->findById($testEntity->getId())); } diff --git a/tests/Services/TagServiceTest.php b/tests/Services/TagServiceTest.php index 2ec61a6d..32e6dff8 100644 --- a/tests/Services/TagServiceTest.php +++ b/tests/Services/TagServiceTest.php @@ -25,7 +25,7 @@ final class TagServiceTest extends AbstractDatabaseTestCase $tagService = $this->getTagService(); $result = $tagService->createTags([$tag]); $this->assertEquals(1, count($result)); - $this->assertEquals(1, $result[0]->getId()); + $this->assertNotNull($result[0]->getId()); $this->assertEquals('test', $result[0]->getName()); } @@ -64,7 +64,7 @@ final class TagServiceTest extends AbstractDatabaseTestCase $result = $tagService->createTags([$tag1, $tag2]); $this->assertEquals(2, count($result)); $this->assertEquals(1, $result[0]->getId()); - $this->assertEquals(3, $result[1]->getId()); + $this->assertNotNull($result[1]->getId()); $this->assertEquals('test1', $result[0]->getName()); $this->assertEquals('test3', $result[1]->getName()); }