Skip to content
Permalink
Browse files

Add TestCase method to drop plugins.

Add veneer methods so that folks don't have to interact with
PluginCollection directly if they have to dynamically load plugins. This
lets us match the interface style used for loadPlugins()

Refs #12691
Refs #12687
  • Loading branch information...
markstory committed Nov 4, 2018
1 parent 9f0d448 commit 91b4b45cfc85ba619fdf1d66b932afce16d16d66
Showing with 98 additions and 71 deletions.
  1. +0 −1 config/bootstrap.php
  2. +28 −0 src/TestSuite/TestCase.php
  3. +1 −1 tests/TestCase/Auth/FormAuthenticateTest.php
  4. +1 −1 tests/TestCase/Auth/PasswordHasherFactoryTest.php
  5. +1 −1 tests/TestCase/Cache/CacheTest.php
  6. +2 −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. +2 −2 tests/TestCase/Core/PluginTest.php
  21. +1 −0 tests/TestCase/Datasource/ConnectionManagerTest.php
  22. +1 −1 tests/TestCase/Error/ErrorHandlerTest.php
  23. +1 −1 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
@@ -12,7 +12,6 @@
* @since 0.2.9
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Routing\Router;
define('TIME_START', microtime(true));
@@ -15,6 +15,7 @@
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Datasource\ConnectionManager;
use Cake\Event\EventManager;
use Cake\Http\BaseApplication;
@@ -220,6 +221,33 @@ public function loadPlugins(array $plugins = [])
return $app;
}
/**

Check failure on line 224 in src/TestSuite/TestCase.php

Stickler CI / stickler-ci

src/TestSuite/TestCase.php#L224

Doc comment for parameter "$plugins" missing
* Remove plugins from the global plugin collection.
*
* Useful in test case teardown methods.
*
* @return void
*/
public function removePlugins(array $plugins = [])
{
$collection = Plugin::getCollection();
foreach ($plugins as $plugin) {
$collection->remove($plugin);
}
}
/**
* Clear all plugins from the global plugin collection.
*
* Useful in test case teardown methods.
*
* @return void
*/
public function clearPlugins()
{
Plugin::getCollection()->clear();
}
/**
* Asserts that a global event was fired. You must track events in your event manager for this assertion to work
*
@@ -298,7 +298,7 @@ public function testPluginModel()
'updated' => new Time('2007-03-17 01:18:31')
];
$this->assertEquals($expected, $result);
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -44,7 +44,7 @@ public function testBuild()
$this->loadPlugins(['TestPlugin']);
$hasher = PasswordHasherFactory::build('TestPlugin.Legacy');
$this->assertInstanceof('TestPlugin\Auth\LegacyPasswordHasher', $hasher);
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -315,7 +315,7 @@ public function testConfigWithLibAndPluginEngines()
Cache::drop('libEngine');
Cache::drop('pluginLibEngine');
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -34,7 +34,6 @@ public function setUp()
parent::setUp();
$this->setAppNamespace();
$this->useCommandRunner(true);
Plugin::getCollection()->clear();
$app = $this->getMockForAbstractClass(
BaseApplication::class,
['']
@@ -50,7 +49,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -63,7 +62,7 @@ public function testMainNoCommandsFallback()
$this->exec('help');
$this->assertExitCode(Shell::CODE_SUCCESS);
$this->assertCommandList();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -296,6 +296,6 @@ public function testDiscoverPlugin()
'Long names are stored as well'
);
$this->assertSame($result['company'], $result['company/test_plugin_three.company']);
Plugin::getCollection()->clear();
$this->clearPlugins();
}
}
@@ -127,6 +127,6 @@ public function testLoadWithAlias()
$result = $this->helpers->loaded();
$this->assertEquals(['SimpleAliased', 'SomeHelper'], $result, 'loaded() results are wrong.');
Plugin::getCollection()->clear();
$this->clearPlugins();
}
}
@@ -49,7 +49,7 @@ public function tearDown()
{
parent::tearDown();
ShellDispatcher::resetAliases();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -141,7 +141,7 @@ public function testInitialize()
'TestPlugin\Model\Table\TestPluginCommentsTable',
$this->Shell->TestPluginComments
);
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -170,7 +170,7 @@ public function testLoadModel()
'TestPlugin\Model\Table\TestPluginCommentsTable',
$this->Shell->TestPluginComments
);
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -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::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -119,6 +119,6 @@ public function testLoadWithAlias()
$result = $this->Tasks->loaded();
$this->assertEquals(['CommandAliased', 'SomeTask'], $result, 'loaded() results are wrong.');
Plugin::getCollection()->clear();
$this->clearPlugins();
}
}
@@ -54,7 +54,7 @@ public function tearDown()
{
parent::tearDown();
unset($this->Components);
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -257,7 +257,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -32,7 +32,7 @@ class AppTest extends TestCase
public function tearDown()
{
parent::tearDown();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -39,7 +39,7 @@ class BasePluginTest extends TestCase
public function tearDown()
{
parent::tearDown();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -221,7 +221,7 @@ public function testReadPluginValue()
$result = $engine->read('TestPlugin.nested');
$this->assertEquals('foo', $result['database']['db']['password']);
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -142,7 +142,7 @@ public function testReadPluginValue()
$result = $engine->read('TestPlugin.load');
$this->assertArrayHasKey('plugin_load', $result);
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -128,7 +128,7 @@ public function testReadPluginValue()
$result = $engine->read('TestPlugin.load');
$this->assertArrayHasKey('plugin_load', $result);
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -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::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -32,7 +32,7 @@ class PluginTest extends TestCase
public function setUp()
{
parent::setUp();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -43,7 +43,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -68,6 +68,7 @@ class ConnectionManagerTest extends TestCase
public function tearDown()
{
parent::tearDown();
$this->clearPlugins();
Plugin::getCollection()->clear();
ConnectionManager::drop('test_variant');
ConnectionManager::dropAlias('other_name');
@@ -112,7 +112,7 @@ public function tearDown()
{
parent::tearDown();
Log::reset();
Plugin::getCollection()->clear();
$this->clearPlugins();
if ($this->_restoreError) {
restore_error_handler();
restore_exception_handler();
@@ -183,7 +183,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::getCollection()->clear();
$this->clearPlugins();
if ($this->_restoreError) {
restore_error_handler();
}
@@ -49,7 +49,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -88,7 +88,7 @@ public function tearDown()
{
unset($_SESSION);
parent::tearDown();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -56,7 +56,7 @@ public function tearDown()
I18n::clear();
I18n::setDefaultFormatter('default');
I18n::setLocale($this->locale);
Plugin::getCollection()->clear();
$this->clearPlugins();
Cache::clear(false, '_cake_core_');
}
@@ -64,7 +64,7 @@ public function testImportingLoggers()
Log::write(LOG_INFO, 'TestPluginLog is not a BaseLog descendant');
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -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::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -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::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -540,7 +540,7 @@ public function testTargetPlugin()
$this->assertSame('TestPlugin.ThisAssociationName', $table->getRegistryAlias());
$this->assertSame('comments', $table->getTable());
$this->assertSame('ThisAssociationName', $table->getAlias());
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -46,7 +46,7 @@ public function setUp()
*/
public function tearDown()
{
Plugin::getCollection()->clear();
$this->clearPlugins();
unset($this->Table, $this->EventManager, $this->Behaviors);
parent::tearDown();
}
@@ -68,7 +68,7 @@ public function setUp()
*/
public function tearDown()
{
Plugin::getCollection()->clear();
$this->clearPlugins();
parent::tearDown();
}
@@ -545,7 +545,7 @@ public function testPluginAssociationQueryGeneration()
$result->author->id,
'No SQL error and author exists.'
);
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -398,7 +398,7 @@ public function testSourceOnContainAssociations()
})->first();
$this->assertEquals('TestPlugin.Comments', $result->getSource());
$this->assertEquals('TestPlugin.Authors', $result->_matchingData['Authors']->getSource());
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -128,7 +128,7 @@ public function tearDown()
{
parent::tearDown();
$this->getTableLocator()->clear();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
@@ -61,7 +61,7 @@ public function tearDown()
{
error_reporting($this->errorLevel);
parent::tearDown();
Plugin::getCollection()->clear();
$this->clearPlugins();
}
/**
Oops, something went wrong.

0 comments on commit 91b4b45

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