diff --git a/plugins/baser-core/src/View/Helper/BcContentsHelper.php b/plugins/baser-core/src/View/Helper/BcContentsHelper.php index ed591fc408..91da6b438a 100644 --- a/plugins/baser-core/src/View/Helper/BcContentsHelper.php +++ b/plugins/baser-core/src/View/Helper/BcContentsHelper.php @@ -324,6 +324,7 @@ public function getTree($id = 1, $level = null, $options = []) * @return EntityInterface|array|false * @checked * @noTodo + * @unitTest */ public function getParent($id = null, $direct = true) { diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php index 9a96d3ceee..264048c271 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php @@ -25,6 +25,7 @@ use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcUtil; use BaserCore\View\Helper\BcContentsHelper; +use Cake\Utility\Hash; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; /** @@ -424,19 +425,18 @@ public static function getJsonItemsDataProvider() */ public function testGetParent($expected, $id, $direct) { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); if (is_string($id)) { - $this->BcContents->request = $this->_getRequest($id); + $this->BcContents = new BcContentsHelper(new BcAdminAppView($this->getRequest($id))); $id = null; } $result = $this->BcContents->getParent($id, $direct); if ($direct) { if ($result) { - $result = $result['Content']['id']; + $result = $result->id; } } else { if ($result) { - $result = Hash::extract($result, '{n}.Content.id'); + $result = Hash::extract($result, '{n}.id'); } } $this->assertEquals($expected, $result); @@ -448,12 +448,12 @@ public static function getParentDataProvider() [1, 4, true], // ダイレクト ROOT直下 [21, 22, true], // ダイレクト フォルダ内 [false, 1, true], // ダイレクト ルートフォルダ - [false, 100, true], // ダイレクト 存在しないコンテンツ - [[1, 21], 24, false], // パス 2階層配下 - [[1, 21, 24], 25, false], // パス 3階層配下 - [[3, 26], 12, false], // パス スマホ2階層配下 - [false, 100, false], // パス 存在しないコンテンツ - [[1, 21, 24], '/service/sub_service/sub_service_1', false] // パス URLで解決 + [false, 1, true], // ダイレクト 存在しないコンテンツ + [[24], 27, false], // パス 2階層配下 + [[24], 25, false], // パス 3階層配下 + [[1, 6], 12, false], // パス スマホ2階層配下 + [false, '/service/service2/test', true], // パス 存在しないコンテンツ + [[1, 6], '/service/service2', false] // パス URLで解決 ]; }