commit(); $this->article1Id = $article1->getId(); $this->article2Id = $article2->getId(); $this->article3Id = $article3->getId(); } /** * @throws StatusException */ function testGetDoArticles() { $response = TestEnv::http()->newRequest() ->get(['api', 'articles']) ->exec(); $articleStructs = $response->parseJson(); $this->assertCount(3, $articleStructs); $this->assertEquals('Title 1', $articleStructs[0]['title']); $this->assertEquals('Title 2', $articleStructs[1]['title']); $this->assertEquals('Title 3', $articleStructs[2]['title']); } function testGetArticleById() { // $articlePOST = ArticleTestEnv::getArticleById($this->article3Id); $response = TestEnv::http()->newRequest() ->get(['api', 'articles']) ->exec(); $articleStructs = $response->parseJson(); $this->assertEquals('Title 3', $articleStructs[2]['title']); } function testPostDoArticle() { $tx = TestEnv::createTransaction(); $articlePOST = ArticleTestEnv::setUpArticle('Title POST', 'Loren ipsum POST', 'teaser POST'); $tx->commit(); $this->articlePOSTId = $articlePOST->getId(); $response = TestEnv::http()->newRequest() ->get(['api', 'articles']) ->exec(); $articleStructs = $response->parseJson(); $this->assertCount(4, $articleStructs); } function testPutDoArticle() { $tx = TestEnv::createTransaction(); ArticleTestEnv::updateArticle(1, 'Title PUT', 'Loren ipsum PUT', 'teaser PUT'); $tx->commit(); $response = TestEnv::http()->newRequest() ->get(['api', 'articles']) ->exec(); $articleStructs = $response->parseJson(); $this->assertCount(3, $articleStructs); $this->assertEquals('Title PUT', $articleStructs[2]['title']); //var_dump($articleStructs); } function testDeleteDoArticle() { $tx = TestEnv::createTransaction(); ArticleTestEnv::removeArticle(3); $tx->commit(); $response = TestEnv::http()->newRequest() ->get(['api', 'articles']) ->exec(); $articleStructs = $response->parseJson(); $this->assertCount(2, $articleStructs); } }