Gabriyel Goede 1 bulan lalu
induk
melakukan
c0cca77ab0

+ 1 - 1
.gitignore

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

File diff ditekan karena terlalu besar
+ 0 - 0
src-php/.phpunit.result.cache


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

@@ -81,7 +81,7 @@ class ArticleApiController extends ControllerAdapter {
 	 * @return void
 	 */
 	function getDoArticles(?string $categoryName = null): void {
-		if($categoryName === null) {
+		if ($categoryName === null) {
 			$articles = $this->articleDao->getArticles();
 			if($articles === []) {
 				throw new PageNotFoundException('No articles found');

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

@@ -6,6 +6,8 @@ use PHPUnit\Framework\TestCase;
 use n2n\test\TestEnv;
 use internship\test\ArticleTestEnv;
 use util\GeneralTestEnv;
+use n2n\web\http\StatusException;
+
 use n2n\web\http\PageNotFoundException;
 use internship\bo\Article;
 use n2n\web\http\BadRequestException;
@@ -30,6 +32,9 @@ class ArticleControllerTest extends TestCase {
 		$this->article3Id = $article3->getId();
 	}
 
+	/**
+	 * @throws StatusException
+	 */
 	function testGetDoArticles() {
 		$response = TestEnv::http()->newRequest()
 				->get(['api', 'articles'])
@@ -232,4 +237,15 @@ class ArticleControllerTest extends TestCase {
 			$tx->commit();
 	}
 
+	/**
+	 * @throws StatusException
+	 */
+	function testGetDoArticlesByCategoryName() {
+		$response = TestEnv::http()->newRequest()
+				->get(['api', 'articles', 'news'])
+				->exec();
+
+	}
+
+
 }

+ 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;
 	}
  }

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini