-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '5.1.x' of github.com:baserproject/basercms into 5.1.x
- Loading branch information
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
plugins/baser-core/tests/TestCase/Utility/BcPluginUtilTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace BaserCore\Test\TestCase\Utility; | ||
|
||
use BaserCore\TestSuite\BcTestCase; | ||
use BaserCore\Utility\BcPluginUtil; | ||
use BaserCore\Utility\BcUtil; | ||
|
||
class BcPluginUtilTest extends BcTestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* test getPluginConfig | ||
* @param string $pluginName | ||
* @param string|null $configContent | ||
* @param array $expected | ||
* @dataProvider getPluginConfigDataProvider | ||
*/ | ||
public function testGetPluginConfig($pluginName, $configContent, $expected) | ||
{ | ||
//create config file | ||
$configPath = BcUtil::getPluginPath($pluginName) . 'config.php'; | ||
if ($configContent !== null) { | ||
file_put_contents($configPath, $configContent); | ||
} | ||
|
||
$result = BcPluginUtil::getPluginConfig($pluginName); | ||
|
||
$this->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', | ||
'<?php return [\'type\' => \'Plugin\', \'title\' => \'Test Plugin\'];', | ||
[ | ||
'type' => ['Plugin'], | ||
'title' => 'Test Plugin', | ||
'description' => '', | ||
'author' => '', | ||
'url' => '', | ||
'adminLink' => '', | ||
'installMessage' => '', | ||
] | ||
], | ||
|
||
[ | ||
'test_plugin', | ||
'<?php return [\'type\' => \'Plugin,CorePlugin\', \'title\' => \'Test Plugin\'];', | ||
[ | ||
'type' => ['Plugin', 'CorePlugin'], | ||
'title' => 'Test Plugin', | ||
'description' => '', | ||
'author' => '', | ||
'url' => '', | ||
'adminLink' => '', | ||
'installMessage' => '', | ||
] | ||
] | ||
]; | ||
} | ||
} |