Skip to content

Commit

Permalink
CustomContentsController::view のユニットテスト (#2759)
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 25, 2023
1 parent 72de951 commit 48fb9d9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function index(CustomContentsServiceInterface $service)
*
* @checked
* @noTodo
* @unitTest
*/
public function view(CustomContentsServiceInterface $service, int $id)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,31 @@ public function test_add()
$this->assertEquals('関連するコンテンツがありません', $result->errors->content->_required);
}

/**
* test view
*/
public function test_view()
{
//データを生成
$this->loadFixtureScenario(CustomContentsScenario::class);
//APIを呼ぶ
$this->get('/baser/api/admin/bc-custom-content/custom_contents/view/1.json?token=' . $this->accessToken);
//ステータスを確認
$this->assertResponseOk();
//戻る値を確認
$result = json_decode((string)$this->_response->getBody());
$this->assertEquals($result->customContent->description, 'サービステスト');
$this->assertEquals($result->customContent->content->url, '/');

//エラーを発生した時の確認
$this->get('/baser/api/admin/bc-custom-content/custom_contents/view/10.json?token=' . $this->accessToken);
//ステータスを確認
$this->assertResponseCode(404);
//戻る値を確認
$result = json_decode((string)$this->_response->getBody());
$this->assertEquals('データが見つかりません。', $result->message);
}

/**
* test edit
*/
Expand Down

0 comments on commit 48fb9d9

Please sign in to comment.