|
@@ -19,9 +19,9 @@ class ArticleControllerTest extends TestCase {
|
|
|
GeneralTestEnv::tearDown();
|
|
GeneralTestEnv::tearDown();
|
|
|
|
|
|
|
|
$tx = TestEnv::createTransaction();
|
|
$tx = TestEnv::createTransaction();
|
|
|
- $article1 = ArticleTestEnv::setUpArticle('Title 1', 'Loren ipsum 1', 'teaser');
|
|
|
|
|
|
|
+ $article1 = ArticleTestEnv::setUpArticle('Title 3', 'Loren ipsum 1', 'teaser');
|
|
|
$article2 = ArticleTestEnv::setUpArticle('Title 2', 'Loren ipsum 2', 'news');
|
|
$article2 = ArticleTestEnv::setUpArticle('Title 2', 'Loren ipsum 2', 'news');
|
|
|
- $article3 = ArticleTestEnv::setUpArticle('Title 3', 'Loren ipsum 3', 'news');
|
|
|
|
|
|
|
+ $article3 = ArticleTestEnv::setUpArticle('Title 1', 'Loren ipsum 3', 'news');
|
|
|
$tx->commit();
|
|
$tx->commit();
|
|
|
|
|
|
|
|
$this->article1Id = $article1->getId();
|
|
$this->article1Id = $article1->getId();
|
|
@@ -46,36 +46,62 @@ class ArticleControllerTest extends TestCase {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function testGetArticleById() {
|
|
function testGetArticleById() {
|
|
|
|
|
+
|
|
|
|
|
+ // $articlePOST = ArticleTestEnv::getArticleById($this->article3Id);
|
|
|
|
|
+
|
|
|
$response = TestEnv::http()->newRequest()
|
|
$response = TestEnv::http()->newRequest()
|
|
|
- ->get(['api', 'articles'])
|
|
|
|
|
- ->exec();
|
|
|
|
|
|
|
+ ->get(['api', 'articles'])
|
|
|
|
|
+ ->exec();
|
|
|
|
|
|
|
|
$articleStructs = $response->parseJson();
|
|
$articleStructs = $response->parseJson();
|
|
|
- $this->assertCount(3, $articleStructs);
|
|
|
|
|
|
|
|
|
|
- $id = 3;
|
|
|
|
|
$this->assertEquals('Title 3', $articleStructs[2]['title']);
|
|
$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 testDeleteDoArticle() {
|
|
|
|
|
|
|
+ function testPutDoArticle() {
|
|
|
|
|
+
|
|
|
|
|
+ $tx = TestEnv::createTransaction();
|
|
|
|
|
+ ArticleTestEnv::updateArticle(1, 'Title PUT', 'Loren ipsum PUT', 'teaser PUT');
|
|
|
|
|
+ $tx->commit();
|
|
|
|
|
|
|
|
$response = TestEnv::http()->newRequest()
|
|
$response = TestEnv::http()->newRequest()
|
|
|
->get(['api', 'articles'])
|
|
->get(['api', 'articles'])
|
|
|
->exec();
|
|
->exec();
|
|
|
|
|
|
|
|
$articleStructs = $response->parseJson();
|
|
$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);
|
|
ArticleTestEnv::removeArticle(3);
|
|
|
- $this->assertCount(2, $articleStructs);
|
|
|
|
|
|
|
+ $tx->commit();
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- $this->assertEquals('Title 3', $articleStructs[2]['title']);
|
|
|
|
|
|
|
+ $response = TestEnv::http()->newRequest()
|
|
|
|
|
+ ->get(['api', 'articles'])
|
|
|
|
|
+ ->exec();
|
|
|
|
|
|
|
|
$articleStructs = $response->parseJson();
|
|
$articleStructs = $response->parseJson();
|
|
|
- $this->assertCount(3, $articleStructs);
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ $this->assertCount(2, $articleStructs);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|