Skip to content

Commit

Permalink
CustomLinksController::get_parent_list のユニットテスト (#2750)
Browse files Browse the repository at this point in the history
Co-authored-by: Đỗ Văn Hùng <[email protected]>
  • Loading branch information
HungDV2022 and dovanhung authored Sep 22, 2023
1 parent a4c243e commit 49bb848
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public function list(CustomLinksServiceInterface $service, int $id)
*
* @param CustomLinksServiceInterface $service
* @param int $tableId
* @unitTest
*/
public function get_parent_list(CustomLinksServiceInterface $service, int $tableId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,32 @@ public function test_list()
$this->assertEquals('求人分類', $result->customLinks->{1});
$this->assertEquals('この仕事の特徴', $result->customLinks->{2});
}

/**
* test get_parent_list
*/
public function test_get_parent_list()
{
//データを生成
$dataBaseService = $this->getService(BcDatabaseServiceInterface::class);
$customTable = $this->getService(CustomTablesServiceInterface::class);
$customTable->create([
'id' => 1,
'name' => 'recruit_category',
'title' => '求人情報',
'type' => '1',
'display_field' => 'title',
'has_child' => 0
]);
//APIを呼ぶ
$this->post('/baser/api/admin/bc-custom-content/custom_links/get_parent_list/1.json?token=' . $this->accessToken);
//ステータスを確認
$this->assertResponseOk();
//戻る値を確認
$result = json_decode((string)$this->_response->getBody());
$this->assertNotNull($result->parentList);

//不要なテーブルを削除
$dataBaseService->dropTable('custom_entry_1_recruit_category');
}
}

0 comments on commit 49bb848

Please sign in to comment.