First draft for plugins system
This commit is contained in:
23
tests/units/Core/PluginLoaderTest.php
Normal file
23
tests/units/Core/PluginLoaderTest.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../Base.php';
|
||||
|
||||
use Core\PluginLoader;
|
||||
|
||||
class PluginLoaderTest extends Base
|
||||
{
|
||||
public function testGetSchemaVersion()
|
||||
{
|
||||
$p = new PluginLoader($this->container);
|
||||
$this->assertEquals(0, $p->getSchemaVersion('not_found'));
|
||||
|
||||
$this->assertTrue($p->setSchemaVersion('plugin1', 1));
|
||||
$this->assertEquals(1, $p->getSchemaVersion('plugin1'));
|
||||
|
||||
$this->assertTrue($p->setSchemaVersion('plugin2', 33));
|
||||
$this->assertEquals(33, $p->getSchemaVersion('plugin2'));
|
||||
|
||||
$this->assertTrue($p->setSchemaVersion('plugin1', 2));
|
||||
$this->assertEquals(2, $p->getSchemaVersion('plugin1'));
|
||||
}
|
||||
}
|
||||
28
tests/units/Core/TemplateTest.php
Normal file
28
tests/units/Core/TemplateTest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../Base.php';
|
||||
|
||||
use Core\Template;
|
||||
|
||||
class TemplateTest extends Base
|
||||
{
|
||||
public function testGetTemplateFile()
|
||||
{
|
||||
$t = new Template($this->container);
|
||||
$this->assertStringEndsWith('app/Core/../Template/a/b.php', $t->getTemplateFile('a/b'));
|
||||
}
|
||||
|
||||
public function testGetPluginTemplateFile()
|
||||
{
|
||||
$t = new Template($this->container);
|
||||
$this->assertStringEndsWith('app/Core/../../plugins/Myplugin/Template/a/b.php', $t->getTemplateFile('myplugin:a/b'));
|
||||
}
|
||||
|
||||
public function testGetOverridedTemplateFile()
|
||||
{
|
||||
$t = new Template($this->container);
|
||||
$t->setTemplateOverride('a/b', 'myplugin:c');
|
||||
$this->assertStringEndsWith('app/Core/../../plugins/Myplugin/Template/c.php', $t->getTemplateFile('a/b'));
|
||||
$this->assertStringEndsWith('app/Core/../Template/d.php', $t->getTemplateFile('d'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user