Skip to content

Commit

Permalink
admin_ThemeFilesController::delete_folder ユニットテスト
Browse files Browse the repository at this point in the history
  • Loading branch information
dovanhung committed Oct 13, 2023
1 parent 83d3256 commit f1fbedf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public function delete(ThemeFilesAdminServiceInterface $service)
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function delete_folder(ThemeFoldersAdminServiceInterface $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\BcFolder;
use BcThemeFile\Controller\Admin\ThemeFilesController;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;

Expand Down Expand Up @@ -132,7 +133,20 @@ public function test_delete()
*/
public function test_delete_folder()
{
$this->markTestIncomplete('このテストは未実装です。');
$this->enableSecurityToken();
$this->enableCsrfToken();
//テストテーマフォルダを作成
$fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout';
$folder = new BcFolder($fullpath . DS . 'delete_folder');
$folder->create();
//Postメソッドを検証場合
$this->post('/baser/admin/bc-theme-file/theme_files/delete_folder/BcThemeSample/layout/delete_folder');
//戻る値を確認
$this->assertResponseCode(302);
$this->assertFlashMessage('フォルダ delete_folder を削除しました。');
$this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout/');
//実際にフォルダが削除されいてるか確認すること
$this->assertFalse(file_exists($fullpath . 'delete_folder'));
}

/**
Expand Down

0 comments on commit f1fbedf

Please sign in to comment.