|
|
@@ -53,9 +53,11 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoad()
|
|
|
{
|
|
|
- Plugin::load('TestPlugin');
|
|
|
- $expected = ['TestPlugin'];
|
|
|
- $this->assertEquals($expected, Plugin::loaded());
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::load('TestPlugin');
|
|
|
+ $expected = ['TestPlugin'];
|
|
|
+ $this->assertEquals($expected, Plugin::loaded());
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -65,9 +67,11 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadConcreteClass()
|
|
|
{
|
|
|
- Plugin::load('TestPlugin');
|
|
|
- $instance = Plugin::getCollection()->get('TestPlugin');
|
|
|
- $this->assertSame(TestPlugin::class, get_class($instance));
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::load('TestPlugin');
|
|
|
+ $instance = Plugin::getCollection()->get('TestPlugin');
|
|
|
+ $this->assertSame(TestPlugin::class, get_class($instance));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -77,9 +81,11 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadDynamicClass()
|
|
|
{
|
|
|
- Plugin::load('TestPluginTwo');
|
|
|
- $instance = Plugin::getCollection()->get('TestPluginTwo');
|
|
|
- $this->assertSame(BasePlugin::class, get_class($instance));
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::load('TestPluginTwo');
|
|
|
+ $instance = Plugin::getCollection()->get('TestPluginTwo');
|
|
|
+ $this->assertSame(BasePlugin::class, get_class($instance));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -89,14 +95,14 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testUnload()
|
|
|
{
|
|
|
- Plugin::load('TestPlugin');
|
|
|
+ $this->loadPlugins(['TestPlugin' => ['bootstrap' => false, 'routes' => false]]);
|
|
|
$expected = ['TestPlugin'];
|
|
|
$this->assertEquals($expected, Plugin::loaded());
|
|
|
|
|
|
Plugin::unload('TestPlugin');
|
|
|
$this->assertEquals([], Plugin::loaded());
|
|
|
|
|
|
- Plugin::load('TestPlugin');
|
|
|
+ $this->loadPlugins(['TestPlugin' => ['bootstrap' => false, 'routes' => false]]);
|
|
|
$expected = ['TestPlugin'];
|
|
|
$this->assertEquals($expected, Plugin::loaded());
|
|
|
|
|
|
@@ -111,14 +117,16 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadWithAutoload()
|
|
|
{
|
|
|
- $this->assertFalse(class_exists('Company\TestPluginFive\Utility\Hello'));
|
|
|
- Plugin::load('Company/TestPluginFive', [
|
|
|
- 'autoload' => true,
|
|
|
- ]);
|
|
|
- $this->assertTrue(
|
|
|
- class_exists('Company\TestPluginFive\Utility\Hello'),
|
|
|
- 'Class should be loaded'
|
|
|
- );
|
|
|
+ $this->deprecated(function () {
|
|
|
+ $this->assertFalse(class_exists('Company\TestPluginFive\Utility\Hello'));
|
|
|
+ Plugin::load('Company/TestPluginFive', [
|
|
|
+ 'autoload' => true,
|
|
|
+ ]);
|
|
|
+ $this->assertTrue(
|
|
|
+ class_exists('Company\TestPluginFive\Utility\Hello'),
|
|
|
+ 'Class should be loaded'
|
|
|
+ );
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -128,19 +136,21 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadWithAutoloadAndBootstrap()
|
|
|
{
|
|
|
- Plugin::load(
|
|
|
- 'Company/TestPluginFive',
|
|
|
- [
|
|
|
- 'autoload' => true,
|
|
|
- 'bootstrap' => true
|
|
|
- ]
|
|
|
- );
|
|
|
- $this->assertTrue(Configure::read('PluginTest.test_plugin_five.autoload'));
|
|
|
- $this->assertEquals('loaded plugin five bootstrap', Configure::read('PluginTest.test_plugin_five.bootstrap'));
|
|
|
- $this->assertTrue(
|
|
|
- class_exists('Company\TestPluginFive\Utility\Hello'),
|
|
|
- 'Class should be loaded'
|
|
|
- );
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::load(
|
|
|
+ 'Company/TestPluginFive',
|
|
|
+ [
|
|
|
+ 'autoload' => true,
|
|
|
+ 'bootstrap' => true
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ $this->assertTrue(Configure::read('PluginTest.test_plugin_five.autoload'));
|
|
|
+ $this->assertEquals('loaded plugin five bootstrap', Configure::read('PluginTest.test_plugin_five.bootstrap'));
|
|
|
+ $this->assertTrue(
|
|
|
+ class_exists('Company\TestPluginFive\Utility\Hello'),
|
|
|
+ 'Class should be loaded'
|
|
|
+ );
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -150,13 +160,15 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadWithBootstrap()
|
|
|
{
|
|
|
- Plugin::load('TestPlugin', ['bootstrap' => true]);
|
|
|
- $this->assertTrue(Plugin::loaded('TestPlugin'));
|
|
|
- $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::load('TestPlugin', ['bootstrap' => true]);
|
|
|
+ $this->assertTrue(Plugin::loaded('TestPlugin'));
|
|
|
+ $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
|
|
|
|
|
|
- Plugin::load('Company/TestPluginThree', ['bootstrap' => true]);
|
|
|
- $this->assertTrue(Plugin::loaded('Company/TestPluginThree'));
|
|
|
- $this->assertEquals('loaded plugin three bootstrap', Configure::read('PluginTest.test_plugin_three.bootstrap'));
|
|
|
+ Plugin::load('Company/TestPluginThree', ['bootstrap' => true]);
|
|
|
+ $this->assertTrue(Plugin::loaded('Company/TestPluginThree'));
|
|
|
+ $this->assertEquals('loaded plugin three bootstrap', Configure::read('PluginTest.test_plugin_three.bootstrap'));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -166,12 +178,14 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadWithBootstrapDisableBootstrapHook()
|
|
|
{
|
|
|
- Plugin::load('TestPlugin', ['bootstrap' => true]);
|
|
|
- $this->assertTrue(Plugin::loaded('TestPlugin'));
|
|
|
- $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::load('TestPlugin', ['bootstrap' => true]);
|
|
|
+ $this->assertTrue(Plugin::loaded('TestPlugin'));
|
|
|
+ $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
|
|
|
|
|
|
- $plugin = Plugin::getCollection()->get('TestPlugin');
|
|
|
- $this->assertFalse($plugin->isEnabled('bootstrap'), 'Should be disabled as hook has been run.');
|
|
|
+ $plugin = Plugin::getCollection()->get('TestPlugin');
|
|
|
+ $this->assertFalse($plugin->isEnabled('bootstrap'), 'Should be disabled as hook has been run.');
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -199,9 +213,11 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadSingleWithPathConfig()
|
|
|
{
|
|
|
- Configure::write('plugins.TestPlugin', APP);
|
|
|
- Plugin::load('TestPlugin');
|
|
|
- $this->assertEquals(APP . 'src' . DS, Plugin::classPath('TestPlugin'));
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Configure::write('plugins.TestPlugin', APP);
|
|
|
+ Plugin::load('TestPlugin');
|
|
|
+ $this->assertEquals(APP . 'src' . DS, Plugin::classPath('TestPlugin'));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -211,9 +227,11 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadMultiple()
|
|
|
{
|
|
|
- Plugin::load(['TestPlugin', 'TestPluginTwo']);
|
|
|
- $expected = ['TestPlugin', 'TestPluginTwo'];
|
|
|
- $this->assertEquals($expected, Plugin::loaded());
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::load(['TestPlugin', 'TestPluginTwo']);
|
|
|
+ $expected = ['TestPlugin', 'TestPluginTwo'];
|
|
|
+ $this->assertEquals($expected, Plugin::loaded());
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -223,11 +241,13 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadMultipleWithDefaults()
|
|
|
{
|
|
|
- Plugin::load(['TestPlugin', 'TestPluginTwo'], ['bootstrap' => true, 'routes' => false]);
|
|
|
- $expected = ['TestPlugin', 'TestPluginTwo'];
|
|
|
- $this->assertEquals($expected, Plugin::loaded());
|
|
|
- $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
|
|
|
- $this->assertEquals('loaded plugin two bootstrap', Configure::read('PluginTest.test_plugin_two.bootstrap'));
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::load(['TestPlugin', 'TestPluginTwo'], ['bootstrap' => true, 'routes' => false]);
|
|
|
+ $expected = ['TestPlugin', 'TestPluginTwo'];
|
|
|
+ $this->assertEquals($expected, Plugin::loaded());
|
|
|
+ $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
|
|
|
+ $this->assertEquals('loaded plugin two bootstrap', Configure::read('PluginTest.test_plugin_two.bootstrap'));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -237,14 +257,16 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadMultipleWithDefaultsAndOverride()
|
|
|
{
|
|
|
- Plugin::load(
|
|
|
- ['TestPlugin', 'TestPluginTwo' => ['routes' => false]],
|
|
|
- ['bootstrap' => true, 'routes' => true]
|
|
|
- );
|
|
|
- $expected = ['TestPlugin', 'TestPluginTwo'];
|
|
|
- $this->assertEquals($expected, Plugin::loaded());
|
|
|
- $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
|
|
|
- $this->assertNull(Configure::read('PluginTest.test_plugin_two.bootstrap'));
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::load(
|
|
|
+ ['TestPlugin', 'TestPluginTwo' => ['routes' => false]],
|
|
|
+ ['bootstrap' => true, 'routes' => true]
|
|
|
+ );
|
|
|
+ $expected = ['TestPlugin', 'TestPluginTwo'];
|
|
|
+ $this->assertEquals($expected, Plugin::loaded());
|
|
|
+ $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
|
|
|
+ $this->assertNull(Configure::read('PluginTest.test_plugin_two.bootstrap'));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -272,8 +294,10 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadNotFound()
|
|
|
{
|
|
|
- $this->expectException(\Cake\Core\Exception\MissingPluginException::class);
|
|
|
- Plugin::load('MissingPlugin');
|
|
|
+ $this->deprecated(function () {
|
|
|
+ $this->expectException(\Cake\Core\Exception\MissingPluginException::class);
|
|
|
+ Plugin::load('MissingPlugin');
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -283,7 +307,7 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testPath()
|
|
|
{
|
|
|
- Plugin::load(['TestPlugin', 'TestPluginTwo', 'Company/TestPluginThree']);
|
|
|
+ $this->loadPlugins(['TestPlugin', 'TestPluginTwo', 'Company/TestPluginThree']);
|
|
|
$expected = TEST_APP . 'Plugin' . DS . 'TestPlugin' . DS;
|
|
|
$this->assertPathEquals(Plugin::path('TestPlugin'), $expected);
|
|
|
|
|
|
@@ -312,7 +336,7 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testClassPath()
|
|
|
{
|
|
|
- Plugin::load(['TestPlugin', 'TestPluginTwo', 'Company/TestPluginThree']);
|
|
|
+ $this->loadPlugins(['TestPlugin', 'TestPluginTwo', 'Company/TestPluginThree']);
|
|
|
$expected = TEST_APP . 'Plugin' . DS . 'TestPlugin' . DS . 'src' . DS;
|
|
|
$this->assertPathEquals(Plugin::classPath('TestPlugin'), $expected);
|
|
|
|
|
|
@@ -341,12 +365,14 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadAll()
|
|
|
{
|
|
|
- Plugin::loadAll();
|
|
|
- $expected = [
|
|
|
- 'Company', 'ParentPlugin', 'PluginJs', 'TestPlugin',
|
|
|
- 'TestPluginFour', 'TestPluginTwo', 'TestTheme'
|
|
|
- ];
|
|
|
- $this->assertEquals($expected, Plugin::loaded());
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::loadAll();
|
|
|
+ $expected = [
|
|
|
+ 'Company', 'ParentPlugin', 'PluginJs', 'TestPlugin',
|
|
|
+ 'TestPluginFour', 'TestPluginTwo', 'TestTheme'
|
|
|
+ ];
|
|
|
+ $this->assertEquals($expected, Plugin::loaded());
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -356,9 +382,11 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadAllWithPathConfig()
|
|
|
{
|
|
|
- Configure::write('plugins.FakePlugin', APP);
|
|
|
- Plugin::loadAll();
|
|
|
- $this->assertContains('FakePlugin', Plugin::loaded());
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Configure::write('plugins.FakePlugin', APP);
|
|
|
+ Plugin::loadAll();
|
|
|
+ $this->assertContains('FakePlugin', Plugin::loaded());
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -368,9 +396,11 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadAllWithPluginAlreadyLoaded()
|
|
|
{
|
|
|
- Plugin::load('Company/TestPluginThree', ['bootstrap' => false]);
|
|
|
- Plugin::loadAll(['bootstrap' => true, 'ignoreMissing' => true]);
|
|
|
- $this->assertEmpty(Configure::read('PluginTest.test_plugin_three.bootstrap'));
|
|
|
+ $this->deprecated(function () {
|
|
|
+ Plugin::load('Company/TestPluginThree', ['bootstrap' => false]);
|
|
|
+ Plugin::loadAll(['bootstrap' => true, 'ignoreMissing' => true]);
|
|
|
+ $this->assertEmpty(Configure::read('PluginTest.test_plugin_three.bootstrap'));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -380,16 +410,18 @@ class PluginTest extends TestCase
|
|
|
*/
|
|
|
public function testLoadAllWithDefaults()
|
|
|
{
|
|
|
- $defaults = ['bootstrap' => true, 'ignoreMissing' => true];
|
|
|
- Plugin::loadAll([$defaults]);
|
|
|
- $expected = [
|
|
|
- 'Company', 'ParentPlugin', 'PluginJs', 'TestPlugin',
|
|
|
- 'TestPluginFour', 'TestPluginTwo', 'TestTheme'
|
|
|
- ];
|
|
|
- $this->assertEquals($expected, Plugin::loaded());
|
|
|
- $this->assertEquals('loaded js plugin bootstrap', Configure::read('PluginTest.js_plugin.bootstrap'));
|
|
|
- $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
|
|
|
- $this->assertEquals('loaded plugin two bootstrap', Configure::read('PluginTest.test_plugin_two.bootstrap'));
|
|
|
+ $this->deprecated(function () {
|
|
|
+ $defaults = ['bootstrap' => true, 'ignoreMissing' => true];
|
|
|
+ Plugin::loadAll([$defaults]);
|
|
|
+ $expected = [
|
|
|
+ 'Company', 'ParentPlugin', 'PluginJs', 'TestPlugin',
|
|
|
+ 'TestPluginFour', 'TestPluginTwo', 'TestTheme'
|
|
|
+ ];
|
|
|
+ $this->assertEquals($expected, Plugin::loaded());
|
|
|
+ $this->assertEquals('loaded js plugin bootstrap', Configure::read('PluginTest.js_plugin.bootstrap'));
|
|
|
+ $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
|
|
|
+ $this->assertEquals('loaded plugin two bootstrap', Configure::read('PluginTest.test_plugin_two.bootstrap'));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|