Skip to content

Commit

Permalink
Add unitTest_BcPluginUtil_isTheme
Browse files Browse the repository at this point in the history
  • Loading branch information
thangnn committed Sep 20, 2024
1 parent 6445855 commit a57e0d7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/baser-core/src/Utility/BcPluginUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public static function isPlugin(string $name): bool
* テーマかどうかを判定する
* @param string $name
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public static function isTheme(string $name): bool
{
Expand Down
33 changes: 33 additions & 0 deletions plugins/baser-core/tests/TestCase/Utility/BcPluginUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,37 @@ public static function getPluginConfigDataProvider()
]
];
}

/**
* Test isTheme
* @param string $pluginName
* @param string|null $configContent
* @param bool $expected
* @dataProvider isThemeDataProvider
*/
public function testIsTheme($pluginName, $configContent, $expected)
{
//Create config file
$configPath = BcUtil::getPluginPath($pluginName) . 'config.php';
if ($configContent !== null) {
file_put_contents($configPath, $configContent);
}

$result = BcPluginUtil::isTheme($pluginName);
$this->assertEquals($expected, $result);

//clean up
if (file_exists($configPath)) {
unlink($configPath);
}
}
public static function isThemeDataProvider()
{
return [
['test_theme', '<?php return [\'type\' => \'Theme\'];', true],
['admin_theme', '<?php return [\'type\' => \'AdminTheme\'];', true],
['non_theme', '<?php return [\'type\' => \'SomeOtherType\'];', false],
['non_existent_theme', null, false],
];
}
}

0 comments on commit a57e0d7

Please sign in to comment.