mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-03-07 15:16:40 +08:00
Add test
This commit is contained in:
parent
560ed2c2fd
commit
f117a4f3c7
@ -32,9 +32,10 @@ if (! function_exists('plugin')) {
|
||||
}
|
||||
|
||||
if (! function_exists('plugin_assets')) {
|
||||
function plugin_assets(string $id, string $relativeUri): string
|
||||
function plugin_assets(string $name, string $relativeUri): string
|
||||
{
|
||||
if ($plugin = plugin($id)) {
|
||||
$plugin = plugin($name);
|
||||
if ($plugin) {
|
||||
return $plugin->assets($relativeUri);
|
||||
} else {
|
||||
throw new InvalidArgumentException('No such plugin.');
|
||||
|
@ -449,4 +449,24 @@ class PluginManagerTest extends TestCase
|
||||
$this->assertCount(0, json_decode(resolve(\App\Services\Option::class)->get('plugins_enabled'), true));
|
||||
$this->assertTrue($manager->all()->isEmpty());
|
||||
}
|
||||
|
||||
public function testHelpers()
|
||||
{
|
||||
$manager = app('plugins');
|
||||
$reflection = new ReflectionClass($manager);
|
||||
$property = $reflection->getProperty('plugins');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($manager, collect(['fake' => new Plugin('', ['name' => 'fake', 'version' => '1'])]));
|
||||
|
||||
$this->assertNull(plugin('nope'));
|
||||
$this->assertInstanceOf(Plugin::class, plugin('fake'));
|
||||
|
||||
$this->expectExceptionMessage('No such plugin.');
|
||||
plugin_assets('nope', 'relative');
|
||||
|
||||
$this->assertEquals(
|
||||
url('plugins').'/fake/assets/relative?v=1',
|
||||
plugin_assets('fake', 'relative')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user