commit(); $this->article1Id = $article1->getId(); $this->article2Id = $article2->getId(); $this->article3Id = $article3->getId(); } function testGetDoArticles() { $response = TestEnv::http()->newRequest() ->get(['api', 'articles']) ->exec(); $articleStructs = $response->parseJson(); $this->assertCount(3, $articleStructs); $this->assertEquals('Title 3', $articleStructs[0]['title']); $this->assertEquals('Title 2', $articleStructs[1]['title']); $this->assertEquals('Title 1', $articleStructs[2]['title']); } function testGetDoArticlesWithCategoryName() { $response = TestEnv::http()->newRequest() ->get(['api','articles', 'teaser']) ->exec(); $articleStructs = $response->parseJson(); $this->assertCount(1, $articleStructs); $this->assertEquals('teaser', $articleStructs[0]['categoryName']); } function testGetDoArticlesWithCategoryName2() { $response = TestEnv::http()->newRequest() ->get(['api','articles', 'news']) ->exec(); $articleStructs = $response->parseJson(); $this->assertCount(2, $articleStructs); $this->assertEquals('Title 3', $articleStructs[0]['title']); $this->assertEquals('Title 2', $articleStructs[1]['title']); } function testGetDoArticleById() { $response = TestEnv::http()->newRequest() ->get(['api', 'article', 1]) ->exec(); $articleStructs = $response->parseJson(); $this->assertCount(4, $articleStructs); $this->assertEquals($this->article1Id, $articleStructs['id']); } function testGetDoArticleUnknownId() { $this->expectException(PageNotFoundException::class); $response = TestEnv::http()->newRequest() ->get(['api', 'article', 11]) ->exec(); } }