Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BcThemeFileを全体テストの実行対象に追加する #2830

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
<testsuite name="BcThemeConfig">
<directory>plugins/bc-theme-config/tests/TestCase</directory>
</testsuite>
<!-- <testsuite name="BcThemeFile">-->
<!-- <directory>plugins/bc-theme-file/tests/TestCase</directory>-->
<!-- </testsuite>-->
<testsuite name="BcThemeFile">
<directory>plugins/bc-theme-file/tests/TestCase</directory>
</testsuite>
<!-- <testsuite name="BcUploader">-->
<!-- <directory>plugins/bc-uploader/tests/TestCase</directory>-->
<!-- </testsuite>-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function edit(ThemeFilesAdminServiceInterface $service)
$this->BcMessage->setInfo(sprintf(__d('baser_core', 'ファイル %s を更新しました。'), $themeFile->name));
$this->redirect(array_merge(
[$args['theme'], $args['plugin'], $args['type']],
explode('/', dirname($args['path'])),
(str_contains($args['path'], '/'))? explode('/', dirname($args['path'])) : [],
[$themeFile->name]
));
} catch (BcFormFailedException $e) {
Expand Down Expand Up @@ -242,7 +242,7 @@ public function delete(ThemeFilesAdminServiceInterface $service)

$this->redirect(array_merge(
['action' => 'index', $args['theme'], $args['plugin'], $args['type']],
explode('/', dirname($args['path']))
(str_contains($args['path'], '/'))? explode('/', dirname($args['path'])) : []
));
}

Expand Down Expand Up @@ -270,7 +270,7 @@ public function delete_folder(ThemeFoldersAdminServiceInterface $service)

$this->redirect(array_merge(
['action' => 'index', $args['theme'], $args['plugin'], $args['type']],
explode('/', dirname($args['path']))
(str_contains($args['path'], '/'))? explode('/', dirname($args['path'])) : []
));
}

Expand Down Expand Up @@ -316,7 +316,7 @@ public function copy(ThemeFilesAdminServiceInterface $service)

$this->redirect(array_merge(
['action' => 'index', $args['theme'], $args['plugin'], $args['type']],
explode('/', dirname($args['path']))
(str_contains($args['path'], '/'))? explode('/', dirname($args['path'])) : []
));
}

Expand All @@ -343,7 +343,7 @@ public function copy_folder(ThemeFoldersAdminServiceInterface $service)

$this->redirect(array_merge(
['action' => 'index', $args['theme'], $args['plugin'], $args['type']],
explode('/', dirname($args['path']))
(str_contains($args['path'], '/'))? explode('/', dirname($args['path'])) : []
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,33 +193,29 @@ public function test_edit()
{
$this->enableSecurityToken();
$this->enableCsrfToken();
$fullpath = BASER_PLUGINS . 'BcColumn' . '/layout/';
$fullpath = BASER_PLUGINS . 'BcThemeSample/templates/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');
$this->get('/baser/admin/bc-theme-file/theme_files/edit/BcThemeSample/layout/base_name_1.php');
//取得データを確認
$pageTitle = $this->_controller->viewBuilder()->getVars()['pageTitle'];
$this->assertEquals('BcColumn|レイアウトテンプレート編集', $pageTitle);
$this->assertEquals('BcThemeSample|レイアウトテンプレート編集', $pageTitle);

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

Expand All @@ -239,7 +235,7 @@ public function test_delete()
//戻る値を確認
$this->assertResponseCode(302);
$this->assertFlashMessage('ファイル base_name_1.php を削除しました。');
$this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcColumn/layout/');
$this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcColumn/layout');
//実際にファイルが削除されいてるか確認すること
$this->assertFalse(file_exists($fullpath . 'base_name_1.php'));
}
Expand All @@ -260,7 +256,7 @@ public function test_delete_folder()
//戻る値を確認
$this->assertResponseCode(302);
$this->assertFlashMessage('フォルダ delete_folder を削除しました。');
$this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout/');
$this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout');
//実際にフォルダが削除されいてるか確認すること
$this->assertFalse(file_exists($fullpath . 'delete_folder'));
}
Expand Down Expand Up @@ -300,7 +296,7 @@ public function test_copy()
//戻る値を確認
$this->assertResponseCode(302);
$this->assertFlashMessage('ファイル default.php をコピーしました。');
$this->assertRedirect('baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout/.');
$this->assertRedirect('baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout');
unlink($fullpath . 'default_copy.php');
}

Expand All @@ -321,7 +317,7 @@ public function test_copy_folder()
//戻る値を確認
$this->assertResponseCode(302);
$this->assertFlashMessage('フォルダ new_folder をコピーしました。');
$this->assertRedirect('baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout/.');
$this->assertRedirect('baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout');

//テスト後に不要なフォルダーを削除
$folder->delete();
Expand Down Expand Up @@ -364,7 +360,7 @@ public function test_upload()
unlink($fullpath . 'uploadTestFile.html');

//エラーを発生した場合
$this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout3');
$this->post('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout3');
//ステータスを確認
$this->assertResponseCode(500);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public function test_add()
$fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/';
$data = [
'theme' => 'BcThemeSample',
'parent' => '/var/www/html/plugins/BcThemeSample/templates/layout/',
'plugin' => 'BaserCore',
'type' => 'layout',
'path' => '',
Expand Down Expand Up @@ -146,6 +147,7 @@ public function test_edit()
//Postデータを生成
$data = [
'theme' => 'BcThemeSample',
'parent' => '/var/www/html/plugins/BcThemeSample/templates/layout/',
'plugin' => 'BaserCore',
'type' => 'layout',
'path' => 'new_folder',
Expand Down Expand Up @@ -180,6 +182,7 @@ public function test_delete()
//Postデータを生成
$data = [
'theme' => 'BcThemeSample',
'parent' => '/var/www/html/plugins/BcThemeSample/templates/layout/',
'plugin' => 'BaserCore',
'type' => 'layout',
'path' => 'delete_folder',
Expand Down Expand Up @@ -215,6 +218,7 @@ public function test_copy()
//Postデータを生成
$data = [
'theme' => 'BcThemeSample',
'parent' => '/var/www/html/plugins/BcThemeSample/templates/layout/',
'plugin' => 'BaserCore',
'type' => 'layout',
'path' => 'new_folder',
Expand Down Expand Up @@ -243,6 +247,7 @@ public function test_copy_to_theme()
$fullpath = BASER_PLUGINS . '/BcPluginSample/templates/';
$data = [
'theme' => 'BcFront',
'parent' => '/var/www/html/plugins/BcThemeSample/templates/layout/',
'type' => 'Pages',
'path' => '',
'assets' => '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public function test_get()
$this->assertEquals('php', $rs['ext']);
$this->assertEquals('text', $rs['type']);
$this->assertEquals(null, $rs['path']);
$this->assertTextContains('baserCMS : Based Website Development Project', $rs['contents']);
}

/**
Expand Down