commit(); $this->article1Id = $article1->id; $this->comment1Id = $comment1->id; $this->comment2Id = $comment2->id; $this->comment3Id = $comment3->id; } /** * @throws StatusException */ function testGetDoComments() { $response = TestEnv::http()->newRequest() ->get(['api', 'comment', 'comments']) ->exec(); $commentStructs = $response->parseJson(); $this->assertCount(3, $commentStructs); $this->assertEquals('Hallo das ist ein Test (2) :-)', $commentStructs[0]['text']); $this->assertEquals('Hallo das ist ein Test (1) :-)', $commentStructs[1]['text']); $this->assertEquals('Hallo das ist ein Test (0) :-)', $commentStructs[2]['text']); } /** * @throws StatusException */ function testGetComment() { $response = TestEnv::http()->newRequest() ->get(['api', 'comment', 'comment', $this->article1Id]) ->exec(); $commentStructs = $response->parseJson(); $this->assertEquals('Hallo das ist ein Test (0) :-)', $commentStructs['text']); } /** * @throws StatusException */ function testGetCommentNotFound() { $this->expectException(PageNotFoundException::class); $response = TestEnv::http()->newRequest() ->get(['api', 'comment', 'comment', 1000]) ->exec(); } /** * @throws StatusException */ function testDeleteComment() { $tx = TestEnv::createTransaction(); $comment1 = TestEnv::tem()->find(Comment::class, 1); TestEnv::tem()->remove($comment1); $tx->commit(); $tx = TestEnv::createTransaction(true); $this->assertSame(2, TestEnv::temUtil()->count(Comment::class)); $tx->commit(); } /** * @throws StatusException */ function testDeleteArticleAndOrphanRemovalOfComments() { $tx = TestEnv::createTransaction(true); $this->assertSame(1, TestEnv::temUtil()->count(Article::class)); $this->assertSame(3, TestEnv::temUtil()->count(Comment::class)); $tx->commit(); $tx = TestEnv::createTransaction(); $article = TestEnv::tem()->find(Article::class, 1); TestEnv::tem()->remove($article); $tx->commit(); $tx = TestEnv::createTransaction(true); $this->assertSame(0, TestEnv::temUtil()->count(Article::class)); $this->assertSame(0, TestEnv::temUtil()->count(Comment::class)); $tx->commit(); } }