Andreas von Burg 1 mēnesi atpakaļ
vecāks
revīzija
aa43178fa8

+ 1 - 1
.gitignore

@@ -1,2 +1,2 @@
 /.idea
-/.phpunit.result.cache
+.phpunit.result.cache

+ 1 - 1
src-php/app/internship/controller/ArticleApiController.php

@@ -73,7 +73,7 @@ class ArticleApiController extends ControllerAdapter {
 	 * @return void
 	 */
 	function getDoArticles(?string $categoryName = null): void {
-		if($categoryName === null) {
+		if ($categoryName === null) {
 			$articles = $this->articleDao->getArticles();
 		} else { 
 			$articles = $this->articleDao->getArticlesByCategoryName($categoryName);

+ 19 - 0
src-php/test/internship/controller/ArticleControllerTest.php

@@ -6,6 +6,7 @@ use PHPUnit\Framework\TestCase;
 use n2n\test\TestEnv;
 use internship\test\ArticleTestEnv;
 use util\GeneralTestEnv;
+use n2n\web\http\StatusException;
 
 
 class ArticleControllerTest extends TestCase {
@@ -28,12 +29,16 @@ class ArticleControllerTest extends TestCase {
 		$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 3', $articleStructs[0]['title']);
@@ -41,4 +46,18 @@ class ArticleControllerTest extends TestCase {
 		$this->assertEquals('Title 1', $articleStructs[2]['title']);
 	}
 
+	/**
+	 * @throws StatusException
+	 */
+	function testGetDoArticlesByCategoryName() {
+		$response = TestEnv::http()->newRequest()
+				->get(['api', 'articles', 'news'])
+				->exec();
+
+	}
+
+	function testGetDoArticle() {
+
+	}
+
 }

+ 3 - 0
src-php/test/internship/test/ArticleTestEnv.php

@@ -15,6 +15,9 @@ class ArticleTestEnv  {
 		TestEnv::em()->persist($article);
 		TestEnv::em()->flush();
 
+		// $stmt = $this->pdo->prepare('INSERT INTO article (title, text, categoryName) VALUES (:title, :text:, :categoryName)');
+		// $stmt->exec(['title' => $title, ...])
+
 		return $article;
 	}
  }