From 6445855e3c5487fdd12dce89e119e79346356859 Mon Sep 17 00:00:00 2001 From: thangnnmd <150879641+thangnnmd@users.noreply.github.com> Date: Fri, 20 Sep 2024 07:44:10 +0700 Subject: [PATCH] BcPluginUtil::getPluginConfig (#3827) Co-authored-by: thangnn --- .../baser-core/src/Utility/BcPluginUtil.php | 6 ++ .../TestCase/Utility/BcPluginUtilTest.php | 92 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 plugins/baser-core/tests/TestCase/Utility/BcPluginUtilTest.php diff --git a/plugins/baser-core/src/Utility/BcPluginUtil.php b/plugins/baser-core/src/Utility/BcPluginUtil.php index 4c517e095e..c82cfca8ff 100644 --- a/plugins/baser-core/src/Utility/BcPluginUtil.php +++ b/plugins/baser-core/src/Utility/BcPluginUtil.php @@ -10,6 +10,9 @@ */ namespace BaserCore\Utility; +use BaserCore\Annotation\NoTodo; +use BaserCore\Annotation\Checked; +use BaserCore\Annotation\UnitTest; /** * Class BcPluginUtil @@ -21,6 +24,9 @@ class BcPluginUtil * プラグインのconfig内容を取得する * @param string $name * @return array + * @checked + * @noTodo + * @unitTest */ public static function getPluginConfig(string $name): array { diff --git a/plugins/baser-core/tests/TestCase/Utility/BcPluginUtilTest.php b/plugins/baser-core/tests/TestCase/Utility/BcPluginUtilTest.php new file mode 100644 index 0000000000..da53370ebc --- /dev/null +++ b/plugins/baser-core/tests/TestCase/Utility/BcPluginUtilTest.php @@ -0,0 +1,92 @@ +assertEquals($expected, $result); + + //clean up + if ($configContent !== null) { + unlink($configPath); + } + } + + public static function getPluginConfigDataProvider() + { + return [ + [ + 'non_existent_plugin', + null, + [ + 'type' => [], + 'title' => '', + 'description' => '', + 'author' => '', + 'url' => '', + 'adminLink' => '', + 'installMessage' => '', + ] + ], + + [ + 'test_plugin', + ' \'Plugin\', \'title\' => \'Test Plugin\'];', + [ + 'type' => ['Plugin'], + 'title' => 'Test Plugin', + 'description' => '', + 'author' => '', + 'url' => '', + 'adminLink' => '', + 'installMessage' => '', + ] + ], + + [ + 'test_plugin', + ' \'Plugin,CorePlugin\', \'title\' => \'Test Plugin\'];', + [ + 'type' => ['Plugin', 'CorePlugin'], + 'title' => 'Test Plugin', + 'description' => '', + 'author' => '', + 'url' => '', + 'adminLink' => '', + 'installMessage' => '', + ] + ] + ]; + } +}