Skip to content

Commit

Permalink
add unitTest_WidgetAreasController_add (#3367)
Browse files Browse the repository at this point in the history
Co-authored-by: thangnn <[email protected]>
  • Loading branch information
thangnnmd and thangnn authored Apr 23, 2024
1 parent fd21aa1 commit d7fc85c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function index(WidgetAreasServiceInterface $service)
* @return void|ResponseInterface
* @checked
* @noTodo
* @unitTest
*/
public function add(WidgetAreasServiceInterface $service)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,36 @@ public function testAdmin_index()
*/
public function testAdmin_add()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
$this->loginAdmin($this->getRequest('/'));
$this->enableSecurityToken();
$this->enableCsrfToken();

// データ生成
$data = [
'name' => 'test',
'widgets' => serialize([
[
1 => 'test 1',
2 => 'test 2'
]
])
];

//正常系実行
$this->post('/baser/admin/bc-widget-area/widget_areas/add', $data);
$this->assertResponseCode(302);
$this->assertFlashMessage('新しいウィジェットエリアを保存しました。');
$this->assertRedirect('/baser/admin/bc-widget-area/widget_areas/edit/1');

//データが空の場合、
$data = [
'name' => '',
'widgets' => ''
];
$this->post('/baser/admin/bc-widget-area/widget_areas/add', $data);
$vars = $this->_controller->viewBuilder()->getVars();
$this->assertEquals(['name' => ['_empty' => "ウィジェットエリア名を入力してください。"]], $vars['widgetArea']->getErrors());
$this->assertResponseCode(200);
}

/**
Expand Down

0 comments on commit d7fc85c

Please sign in to comment.