From 2cb0bc4f343b1e367b448d2aaefab02cabb220d4 Mon Sep 17 00:00:00 2001 From: thangnn Date: Fri, 8 Nov 2024 15:50:13 +0700 Subject: [PATCH] Add unitTest_CustomEntriesService_getNew --- .../src/Service/CustomEntriesService.php | 2 ++ .../Service/CustomEntriesServiceTest.php | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/bc-custom-content/src/Service/CustomEntriesService.php b/plugins/bc-custom-content/src/Service/CustomEntriesService.php index 9f8ca6c267..97847df4f5 100644 --- a/plugins/bc-custom-content/src/Service/CustomEntriesService.php +++ b/plugins/bc-custom-content/src/Service/CustomEntriesService.php @@ -76,6 +76,7 @@ class CustomEntriesService implements CustomEntriesServiceInterface * Constructor * @checked * @noTodo + * @unitTest */ public function __construct() { @@ -91,6 +92,7 @@ public function __construct() * @return EntityInterface * @checked * @noTodo + * @unitTest */ public function getNew(int $tableId) { diff --git a/plugins/bc-custom-content/tests/TestCase/Service/CustomEntriesServiceTest.php b/plugins/bc-custom-content/tests/TestCase/Service/CustomEntriesServiceTest.php index 49801644d9..656edb6b9d 100644 --- a/plugins/bc-custom-content/tests/TestCase/Service/CustomEntriesServiceTest.php +++ b/plugins/bc-custom-content/tests/TestCase/Service/CustomEntriesServiceTest.php @@ -87,7 +87,26 @@ public function test_construct() */ public function test_getNew() { - $this->markTestIncomplete('このテストは未実装です。'); + $this->loadFixtureScenario(InitAppScenario::class); + $this->loginAdmin($this->getRequest()); + $customTable = $this->getService(CustomTablesServiceInterface::class); + //カスタムテーブルとカスタムエントリテーブルを生成 + $customTable->create([ + 'id' => 1, + 'name' => 'recruit_categories', + 'title' => '求人情報', + 'type' => '1', + 'display_field' => 'title', + 'has_child' => 0 + ]); + //正常系実行 + $rs = $this->CustomEntriesService->getNew(1); + + $this->assertEquals(1, $rs->custom_table_id); + $this->assertEquals(1, $rs->creator_id); + $this->assertEquals(0, $rs->status); + + $this->CustomEntriesService->dropTable(1); } /**