Skip to content
Merged

#3978 #4111

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion plugins/baser-core/src/BaserCorePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function getAvailableThemes(): array
$themes = [];
foreach($sites as $site) {
if ($site->theme) {
if (!CorePlugin::isLoaded($site->theme) || !is_dir(CorePlugin::path($site->theme))) continue;
if (!CorePlugin::isLoaded($site->theme) && !is_dir(CorePlugin::path($site->theme))) continue;
if(in_array($site->theme, $themes)) continue;
$themes[] = $site->theme;
}
Expand Down
1 change: 1 addition & 0 deletions plugins/baser-core/src/Service/ThemesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ public function loadDefaultDataPattern(string $currentTheme, string $dbDataPatte
* helperとnamespaceを変更する
* @checked
* @notodo
* @unitTest
*/

public function changeHelper(string $newTheme, string $className): bool
Expand Down
29 changes: 29 additions & 0 deletions plugins/baser-core/tests/TestCase/Service/ThemesServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,35 @@ public function testGetDefaultDataPatterns()
$this->assertEquals($expected, $result);
}

/**
* testChangeHelper
*/

public function testChangeHelper()
{
$rs = $this->ThemesService->copy('BcThemeSample');
$this->assertTrue($rs);
//コピーを確認
$this->assertTrue(is_dir(BASER_THEMES . 'BcThemeSampleCopy'), 'テーマのコピーが確認できませんでした。');

$pluginPath = BcUtil::getPluginPath('BcThemeSampleCopy');

// プラグインのnamespace置き換えを確認
$file = new BcFile($pluginPath . 'src' . DS . 'BcThemeSampleCopyPlugin.php');
$data = $file->read();
$this->assertTrue(str_contains($data, 'namespace BcThemeSampleCopy'), 'pluginファイルのnamespace の書き換えが確認できませんでした。');


$file = new BcFile($pluginPath . 'src' . DS . 'View' . DS .'Helper' . DS . 'BcThemeSampleCopyHelper.php');
$data = $file->read();
// ヘルパーのnamespaceの置き換えを確認
$this->assertTrue(str_contains($data, 'namespace BcThemeSampleCopy'), 'Helperファイルのnamespace の書き換えが確認できませんでした。');
// ヘルパーのクラス名書き換えを確認
$this->assertTrue(str_contains($data,'class BcThemeSampleCopyHelper'),'Helperファイルのクラス名の書き換えが確認できませんでした。');

$this->ThemesService->delete('BcThemeSampleCopy');
}

/**
* test copy
* @return void
Expand Down