Skip to content

Commit

Permalink
admin_ThemeFilesController::edit ユニットテスt (#2801)
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 Oct 16, 2023
1 parent 8eba0be commit 85dbdba
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public function add(ThemeFilesAdminServiceInterface $service)
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function edit(ThemeFilesAdminServiceInterface $service)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainerTrait;
use BaserCore\Utility\BcFile;
use BcThemeFile\Controller\Admin\ThemeFilesController;
use Cake\Event\Event;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
Expand Down Expand Up @@ -139,7 +140,36 @@ public function test_add()
*/
public function test_edit()
{
$this->markTestIncomplete('このテストは未実装です。');
$this->enableSecurityToken();
$this->enableCsrfToken();
$fullpath = BASER_PLUGINS . 'BcColumn' . '/layout/';
$file = new BcFile($fullpath . 'base_name_1.php');
$file->create();

//GETメソッドを検証場合
$this->get('/baser/admin/bc-theme-file/theme_files/edit/BcColumn/layout/base_name_1.php');
//取得データを確認
$pageTitle = $this->_controller->viewBuilder()->getVars()['pageTitle'];
$this->assertEquals('BcColumn|レイアウトテンプレート編集', $pageTitle);

$postData = [
'fullpath' => '/var/www/html/plugins/BcColumn/layout/',
'parent' => '/var/www/html/plugins/BcColumn/layout/',
'theme' => 'BcColumn',
'type' => 'layout',
'path' => 'test.php',
'base_name' => 'base_name_2',
'contents' => 'this is a content changed!',
'ext' => 'php',
'plugin' => 'BaserCore'
];
//Postメソッドを検証場合
$this->post('/baser/admin/bc-theme-file/theme_files/edit/BcColumn/layout/base_name_1.php', $postData);
//戻る値を確認
$this->assertResponseCode(302);
$this->assertFlashMessage('ファイル base_name_2.php を更新しました。');
$this->assertRedirect(['action' => 'edit/layout/base_name_2.php']);
unlink($fullpath . 'base_name_2.php');
}

/**
Expand Down

0 comments on commit 85dbdba

Please sign in to comment.