From 3d3beae8bff16a938838b97e4d8584046194a941 Mon Sep 17 00:00:00 2001 From: thangnn Date: Wed, 28 Feb 2024 22:30:53 +0700 Subject: [PATCH] add comment and add unitTest_BlogCategoriesTable_getByName --- plugins/bc-blog/src/Model/Table/BlogCategoriesTable.php | 3 +++ plugins/bc-blog/src/View/Helper/BlogHelper.php | 2 ++ .../tests/TestCase/Model/BlogCategoriesTableTest.php | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/bc-blog/src/Model/Table/BlogCategoriesTable.php b/plugins/bc-blog/src/Model/Table/BlogCategoriesTable.php index 44135afbf5..63410b7e9d 100755 --- a/plugins/bc-blog/src/Model/Table/BlogCategoriesTable.php +++ b/plugins/bc-blog/src/Model/Table/BlogCategoriesTable.php @@ -355,6 +355,9 @@ public function hasChild($id) * @param int $blogContentId * @param string $name * @param array $options + * @notodo + * @checked + * @unitTest * @return EntityInterface */ public function getByName($blogContentId, $name, $options = []) diff --git a/plugins/bc-blog/src/View/Helper/BlogHelper.php b/plugins/bc-blog/src/View/Helper/BlogHelper.php index 2d86e4c038..91010b442d 100755 --- a/plugins/bc-blog/src/View/Helper/BlogHelper.php +++ b/plugins/bc-blog/src/View/Helper/BlogHelper.php @@ -2023,6 +2023,8 @@ public function isSameSiteBlogContent($blogContentId) * @param string $categoryName * @param array $options * @return EntityInterface + * @notodo + * @checked * @unitTest */ public function getCategoryByName($blogContentId, $categoryName = '', $options = []) diff --git a/plugins/bc-blog/tests/TestCase/Model/BlogCategoriesTableTest.php b/plugins/bc-blog/tests/TestCase/Model/BlogCategoriesTableTest.php index 87d1d725a1..8c7cfcccdb 100755 --- a/plugins/bc-blog/tests/TestCase/Model/BlogCategoriesTableTest.php +++ b/plugins/bc-blog/tests/TestCase/Model/BlogCategoriesTableTest.php @@ -498,6 +498,7 @@ public function testHasChild() /** * カテゴリ名よりカテゴリを取得する + * getByName * @dataProvider getByNameDataProvider * @param int $blogCategoryId * @param string $name @@ -505,8 +506,11 @@ public function testHasChild() */ public function testGetByName($blogCategoryId, $name, $expects) { - $this->markTestIncomplete('こちらのテストはまだ未確認です'); - $result = $this->BlogCategory->getByName($blogCategoryId, $name); + //データ生成 + BlogCategoryFactory::make(['name' => 'child', 'blog_content_id' => 1])->persist(); + BlogCategoryFactory::make(['name' => 'name', 'blog_content_id' => 2])->persist(); + $result = $this->BlogCategoriesTable->getByName($blogCategoryId, $name); + //戻り値を確認 $this->assertEquals($expects, (bool)$result); }