Skip to content
Permalink
Browse files

Deprecate Plugin::unload()

I missed this earlier when working on new Plugins. This method should go
away along with `Plugin::load()`.

Refs #12682
  • Loading branch information...
markstory committed Oct 29, 2018
1 parent 3f46964 commit 835a255042beb1d7f3c8b78270cab1c4078fc4d8
Showing with 104 additions and 89 deletions.
  1. +3 −1 src/Core/Plugin.php
  2. +12 −0 src/Core/PluginCollection.php
  3. +0 −1 tests/TestCase/Auth/FormAuthenticateTest.php
  4. +1 −1 tests/TestCase/Auth/PasswordHasherFactoryTest.php
  5. +1 −1 tests/TestCase/Cache/CacheTest.php
  6. +3 −3 tests/TestCase/Command/HelpCommandTest.php
  7. +1 −1 tests/TestCase/Console/CommandCollectionTest.php
  8. +1 −1 tests/TestCase/Console/HelperRegistryTest.php
  9. +1 −1 tests/TestCase/Console/ShellDispatcherTest.php
  10. +2 −2 tests/TestCase/Console/ShellTest.php
  11. +2 −2 tests/TestCase/Console/TaskRegistryTest.php
  12. +1 −1 tests/TestCase/Controller/ComponentRegistryTest.php
  13. +1 −1 tests/TestCase/Controller/ControllerTest.php
  14. +1 −1 tests/TestCase/Core/AppTest.php
  15. +1 −1 tests/TestCase/Core/BasePluginTest.php
  16. +1 −1 tests/TestCase/Core/Configure/Engine/IniConfigTest.php
  17. +1 −1 tests/TestCase/Core/Configure/Engine/JsonConfigTest.php
  18. +1 −1 tests/TestCase/Core/Configure/Engine/PhpConfigTest.php
  19. +1 −1 tests/TestCase/Core/ConfigureTest.php
  20. +21 −18 tests/TestCase/Core/PluginTest.php
  21. +1 −1 tests/TestCase/Datasource/ConnectionManagerTest.php
  22. +1 −1 tests/TestCase/Error/ErrorHandlerTest.php
  23. +1 −2 tests/TestCase/Error/ExceptionRendererTest.php
  24. +1 −1 tests/TestCase/Http/BaseApplicationTest.php
  25. +1 −1 tests/TestCase/Http/SessionTest.php
  26. +1 −1 tests/TestCase/I18n/I18nTest.php
  27. +1 −1 tests/TestCase/Log/LogTest.php
  28. +2 −2 tests/TestCase/Mailer/EmailTest.php
  29. +1 −1 tests/TestCase/ORM/AssociationTest.php
  30. +1 −1 tests/TestCase/ORM/BehaviorRegistryTest.php
  31. +1 −1 tests/TestCase/ORM/Locator/TableLocatorTest.php
  32. +1 −1 tests/TestCase/ORM/QueryRegressionTest.php
  33. +1 −1 tests/TestCase/ORM/ResultSetTest.php
  34. +1 −1 tests/TestCase/ORM/TableTest.php
  35. +1 −1 tests/TestCase/Routing/DispatcherTest.php
  36. +1 −1 tests/TestCase/Routing/Filter/AssetFilterTest.php
  37. +1 −1 tests/TestCase/Routing/Middleware/AssetMiddlewareTest.php
  38. +1 −1 tests/TestCase/Routing/RequestActionTraitTest.php
  39. +1 −1 tests/TestCase/Routing/RouteBuilderTest.php
  40. +2 −2 tests/TestCase/Routing/RouterTest.php
  41. +1 −1 tests/TestCase/Shell/CommandListShellTest.php
  42. +1 −1 tests/TestCase/Shell/CompletionShellTest.php
  43. +1 −1 tests/TestCase/Shell/Task/AssetsTaskTest.php
  44. +1 −1 tests/TestCase/Shell/Task/ExtractTaskTest.php
  45. +1 −1 tests/TestCase/Shell/Task/UnloadTaskTest.php
  46. +1 −1 tests/TestCase/TestSuite/FixtureManagerTest.php
  47. +1 −1 tests/TestCase/TestSuite/IntegrationTestTraitTest.php
  48. +1 −1 tests/TestCase/TestSuite/TestCaseTest.php
  49. +1 −1 tests/TestCase/View/CellTest.php
  50. +1 −1 tests/TestCase/View/Helper/FlashHelperTest.php
  51. +6 −6 tests/TestCase/View/Helper/HtmlHelperTest.php
  52. +2 −2 tests/TestCase/View/Helper/NumberHelperTest.php
  53. +1 −1 tests/TestCase/View/Helper/TextHelperTest.php
  54. +2 −2 tests/TestCase/View/Helper/UrlHelperTest.php
  55. +1 −1 tests/TestCase/View/HelperRegistryTest.php
  56. +1 −1 tests/TestCase/View/HelperTest.php
  57. +1 −1 tests/TestCase/View/StringTemplateTest.php
  58. +1 −1 tests/TestCase/View/ViewTest.php
  59. +1 −1 tests/TestCase/View/Widget/WidgetLocatorTest.php
@@ -381,12 +381,14 @@ public static function loaded($plugin = null)
* Forgets a loaded plugin or all of them if first parameter is null
*
* @param string|null $plugin name of the plugin to forget
* @deprecated 3.7 This method will be removed in 4.0.0. Use PluginCollection::remove() or clear() instead.
* @return void
*/
public static function unload($plugin = null)
{
deprecationWarning('Plugin::unload() will be removed in 4.0. Use PluginCollection::remove() or clear()');
if ($plugin === null) {
static::$plugins = null;
static::getCollection()->clear();
} else {
static::getCollection()->remove($plugin);
}
@@ -158,6 +158,18 @@ public function remove($name)
return $this;
}
/**
* Remove all plugins from the collection
*
* @return $this
*/
public function clear()
{
$this->plugins = [];
return $this;
}
/**
* Check whether the named plugin exists in the collection.
*
@@ -298,7 +298,6 @@ public function testPluginModel()
'updated' => new Time('2007-03-17 01:18:31')
];
$this->assertEquals($expected, $result);
Plugin::unload();
}
/**
@@ -44,7 +44,7 @@ public function testBuild()
$this->loadPlugins(['TestPlugin']);
$hasher = PasswordHasherFactory::build('TestPlugin.Legacy');
$this->assertInstanceof('TestPlugin\Auth\LegacyPasswordHasher', $hasher);
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -315,7 +315,7 @@ public function testConfigWithLibAndPluginEngines()
Cache::drop('libEngine');
Cache::drop('pluginLibEngine');
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -34,7 +34,7 @@ public function setUp()
parent::setUp();
$this->setAppNamespace();
$this->useCommandRunner(true);
Plugin::unload();
Plugin::getCollection()->clear();
$app = $this->getMockForAbstractClass(
BaseApplication::class,
['']
@@ -50,7 +50,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -63,7 +63,7 @@ public function testMainNoCommandsFallback()
$this->exec('help');
$this->assertExitCode(Shell::CODE_SUCCESS);
$this->assertCommandList();
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -296,6 +296,6 @@ public function testDiscoverPlugin()
'Long names are stored as well'
);
$this->assertSame($result['company'], $result['company/test_plugin_three.company']);
Plugin::unload();
Plugin::getCollection()->clear();
}
}
@@ -127,6 +127,6 @@ public function testLoadWithAlias()
$result = $this->helpers->loaded();
$this->assertEquals(['SimpleAliased', 'SomeHelper'], $result, 'loaded() results are wrong.');
Plugin::unload();
Plugin::getCollection()->clear();
}
}
@@ -49,7 +49,7 @@ public function tearDown()
{
parent::tearDown();
ShellDispatcher::resetAliases();
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -141,7 +141,7 @@ public function testInitialize()
'TestPlugin\Model\Table\TestPluginCommentsTable',
$this->Shell->TestPluginComments
);
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -170,7 +170,7 @@ public function testLoadModel()
'TestPlugin\Model\Table\TestPluginCommentsTable',
$this->Shell->TestPluginComments
);
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -94,7 +94,7 @@ public function testLoadPluginTask()
$result = $this->Tasks->load('TestPlugin.OtherTask');
$this->assertInstanceOf('TestPlugin\Shell\Task\OtherTaskTask', $result, 'Task class is wrong.');
$this->assertInstanceOf('TestPlugin\Shell\Task\OtherTaskTask', $this->Tasks->OtherTask, 'Class is wrong');
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -119,6 +119,6 @@ public function testLoadWithAlias()
$result = $this->Tasks->loaded();
$this->assertEquals(['CommandAliased', 'SomeTask'], $result, 'loaded() results are wrong.');
Plugin::unload();
Plugin::getCollection()->clear();
}
}
@@ -54,7 +54,7 @@ public function tearDown()
{
parent::tearDown();
unset($this->Components);
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -257,7 +257,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -32,7 +32,7 @@ class AppTest extends TestCase
public function tearDown()
{
parent::tearDown();
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -39,7 +39,7 @@ class BasePluginTest extends TestCase
public function tearDown()
{
parent::tearDown();
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -221,7 +221,7 @@ public function testReadPluginValue()
$result = $engine->read('TestPlugin.nested');
$this->assertEquals('foo', $result['database']['db']['password']);
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -142,7 +142,7 @@ public function testReadPluginValue()
$result = $engine->read('TestPlugin.load');
$this->assertArrayHasKey('plugin_load', $result);
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -128,7 +128,7 @@ public function testReadPluginValue()
$result = $engine->read('TestPlugin.load');
$this->assertArrayHasKey('plugin_load', $result);
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -406,7 +406,7 @@ public function testLoadPlugin()
$expected = '/test_app/Plugin/TestPlugin/Config/more.load.php';
$config = Configure::read('plugin_more_load');
$this->assertEquals($expected, $config);
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -32,7 +32,7 @@ class PluginTest extends TestCase
public function setUp()
{
parent::setUp();
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -43,7 +43,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -91,26 +91,29 @@ public function testLoadDynamicClass()
/**
* Tests unloading plugins
*
* @deprecated
* @return void
*/
public function testUnload()
{
$this->loadPlugins(['TestPlugin' => ['bootstrap' => false, 'routes' => false]]);
$expected = ['TestPlugin'];
$this->assertEquals($expected, Plugin::loaded());
$this->assertTrue(Plugin::isLoaded('TestPlugin'));
Plugin::unload('TestPlugin');
$this->assertEquals([], Plugin::loaded());
$this->assertFalse(Plugin::isLoaded('TestPlugin'));
$this->loadPlugins(['TestPlugin' => ['bootstrap' => false, 'routes' => false]]);
$expected = ['TestPlugin'];
$this->assertEquals($expected, Plugin::loaded());
Plugin::unload('TestFakePlugin');
$this->assertEquals($expected, Plugin::loaded());
$this->assertFalse(Plugin::isLoaded('TestFakePlugin'));
$this->deprecated(function () {
$this->loadPlugins(['TestPlugin' => ['bootstrap' => false, 'routes' => false]]);
$expected = ['TestPlugin'];
$this->assertEquals($expected, Plugin::loaded());
$this->assertTrue(Plugin::isLoaded('TestPlugin'));
Plugin::unload('TestPlugin');
$this->assertEquals([], Plugin::loaded());
$this->assertFalse(Plugin::isLoaded('TestPlugin'));
$this->loadPlugins(['TestPlugin' => ['bootstrap' => false, 'routes' => false]]);
$expected = ['TestPlugin'];
$this->assertEquals($expected, Plugin::loaded());
Plugin::unload('TestFakePlugin');
$this->assertEquals($expected, Plugin::loaded());
$this->assertFalse(Plugin::isLoaded('TestFakePlugin'));
});
}
/**
@@ -68,7 +68,7 @@ class ConnectionManagerTest extends TestCase
public function tearDown()
{
parent::tearDown();
Plugin::unload();
Plugin::getCollection()->clear();
ConnectionManager::drop('test_variant');
ConnectionManager::dropAlias('other_name');
}
@@ -112,7 +112,7 @@ public function tearDown()
{
parent::tearDown();
Log::reset();
Plugin::unload();
Plugin::getCollection()->clear();
if ($this->_restoreError) {
restore_error_handler();
restore_exception_handler();
@@ -183,7 +183,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::unload();
Plugin::getCollection()->clear();
if ($this->_restoreError) {
restore_error_handler();
}
@@ -884,7 +884,6 @@ public function testMissingPluginRenderSafeWithPlugin()
$body = (string)$response->getBody();
$this->assertContains('test plugin error500', $body);
$this->assertContains('Not Found', $body);
Plugin::unload();
}
/**
@@ -49,7 +49,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -88,7 +88,7 @@ public function tearDown()
{
unset($_SESSION);
parent::tearDown();
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -56,7 +56,7 @@ public function tearDown()
I18n::clear();
I18n::setDefaultFormatter('default');
I18n::setLocale($this->locale);
Plugin::unload();
Plugin::getCollection()->clear();
Cache::clear(false, '_cake_core_');
}
@@ -64,7 +64,7 @@ public function testImportingLoggers()
Log::write(LOG_INFO, 'TestPluginLog is not a BaseLog descendant');
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -1792,7 +1792,7 @@ public function testSendRenderThemed()
$this->assertContains('Message-ID: ', $result['headers']);
$this->assertContains('To: ', $result['headers']);
$this->assertContains('/test_theme/img/test.jpg', $result['message']);
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -1975,7 +1975,7 @@ public function testSendRenderPlugin()
$result = $this->Email->send();
$this->assertContains('Here is your value: 12345', $result['message']);
$this->assertContains('This email was sent using the TestPlugin.', $result['message']);
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -540,7 +540,7 @@ public function testTargetPlugin()
$this->assertSame('TestPlugin.ThisAssociationName', $table->getRegistryAlias());
$this->assertSame('comments', $table->getTable());
$this->assertSame('ThisAssociationName', $table->getAlias());
Plugin::unload();
Plugin::getCollection()->clear();
}
/**
@@ -46,7 +46,7 @@ public function setUp()
*/
public function tearDown()
{
Plugin::unload();
Plugin::getCollection()->clear();
unset($this->Table, $this->EventManager, $this->Behaviors);
parent::tearDown();
}
@@ -68,7 +68,7 @@ public function setUp()
*/
public function tearDown()
{
Plugin::unload();
Plugin::getCollection()->clear();
parent::tearDown();
}
Oops, something went wrong.

0 comments on commit 835a255

Please sign in to comment.
You can’t perform that action at this time.