Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BcContentsHelper::getParent のユニットテスト #3858

Open
wants to merge 1 commit into
base: 5.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/baser-core/src/View/Helper/BcContentsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
Expand All @@ -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で解決
];
}

Expand Down
Loading