Skip to content

Commit

Permalink
unload plugins after use
Browse files Browse the repository at this point in the history
  • Loading branch information
saeideng committed Jul 5, 2018
1 parent b2d58cf commit e0f6112
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 19 deletions.
1 change: 1 addition & 0 deletions tests/TestCase/Http/SessionTest.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\Test\TestCase\Network;

use Cake\Core\Plugin;
use Cake\Http\Session;
use Cake\Http\Session\CacheSession;
use Cake\Http\Session\DatabaseSession;
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/Mailer/EmailTest.php
Expand Up @@ -1763,6 +1763,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();
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/ORM/AssociationTest.php
Expand Up @@ -470,6 +470,7 @@ public function testTargetPlugin()
$this->assertSame('TestPlugin.ThisAssociationName', $table->getRegistryAlias());
$this->assertSame('comments', $table->getTable());
$this->assertSame('ThisAssociationName', $table->getAlias());
Plugin::unload();
}

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/TestCase/ORM/Locator/TableLocatorTest.php
Expand Up @@ -61,6 +61,17 @@ public function setUp()
$this->_locator = new TableLocator;
}

/**
* tearDown
*
* @return void
*/
public function tearDown()
{
Plugin::unload();
parent::tearDown();
}

/**
* Test config() method.
*
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/ORM/QueryRegressionTest.php
Expand Up @@ -545,6 +545,7 @@ public function testPluginAssociationQueryGeneration()
$result->author->id,
'No SQL error and author exists.'
);
Plugin::unload();
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/ORM/ResultSetTest.php
Expand Up @@ -397,6 +397,7 @@ public function testSourceOnContainAssociations()
})->first();
$this->assertEquals('TestPlugin.Comments', $result->getSource());
$this->assertEquals('TestPlugin.Authors', $result->_matchingData['Authors']->getSource());
Plugin::unload();
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -128,6 +128,7 @@ public function tearDown()
{
parent::tearDown();
$this->getTableLocator()->clear();
Plugin::unload();
}

/**
Expand Down
14 changes: 12 additions & 2 deletions tests/TestCase/Routing/Middleware/AssetMiddlewareTest.php
Expand Up @@ -33,8 +33,18 @@ class AssetMiddlewareTest extends TestCase
public function setUp()
{
parent::setUp();
$this->loadPlugins('TestPlugin');
$this->loadPlugins('Company/TestPluginThree');
$this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);
}

/**
* tearDown
*
* @return void
*/
public function tearDown()
{
Plugin::unload();
parent::tearDown();
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/Routing/RequestActionTraitTest.php
Expand Up @@ -65,6 +65,7 @@ public function tearDown()
parent::tearDown();
DispatcherFactory::clear();
Router::reload();
Plugin::unload();

error_reporting($this->errorLevel);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Routing/RouteBuilderTest.php
Expand Up @@ -49,7 +49,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::unload('TestPlugin');
Plugin::unload();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Routing/RouterTest.php
Expand Up @@ -356,7 +356,7 @@ public function testMapResourcesWithExtension()
public function testMapResourcesConnectOptions()
{
$this->deprecated(function () {
$this->loadPlugins('TestPlugin');
Plugin::load('TestPlugin');
Router::mapResources('Posts', [
'connectOptions' => [
'routeClass' => 'TestPlugin.TestRoute',
Expand Down
18 changes: 6 additions & 12 deletions tests/TestCase/Shell/Task/AssetsTaskTest.php
Expand Up @@ -67,8 +67,7 @@ public function tearDown()
*/
public function testSymlink()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins('Company/TestPluginThree');
$this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);

$this->Task->symlink();

Expand Down Expand Up @@ -157,8 +156,7 @@ public function testForPluginWithoutWebroot()
*/
public function testSymlinkingSpecifiedPlugin()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins('Company/TestPluginThree');
$this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);

$this->Task->symlink('TestPlugin');

Expand All @@ -179,8 +177,7 @@ public function testSymlinkingSpecifiedPlugin()
*/
public function testCopy()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins('Company/TestPluginThree');
$this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);

$this->Task->copy();

Expand Down Expand Up @@ -245,8 +242,7 @@ public function testRemoveSymlink()
);
}

$this->loadPlugins('TestPlugin');
$this->loadPlugins('Company/TestPluginThree');
$this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);

mkdir(WWW_ROOT . 'company');

Expand All @@ -273,8 +269,7 @@ public function testRemoveSymlink()
*/
public function testRemoveFolder()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins('Company/TestPluginThree');
$this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);

$this->Task->copy();

Expand All @@ -298,8 +293,7 @@ public function testRemoveFolder()
*/
public function testOverwrite()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins('Company/TestPluginThree');
$this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);

$path = WWW_ROOT . 'test_plugin';

Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/TestSuite/FixtureManagerTest.php
Expand Up @@ -45,6 +45,7 @@ public function tearDown()
{
parent::tearDown();
Log::reset();
Plugin::unload();
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/TestSuite/TestCaseTest.php
Expand Up @@ -465,6 +465,7 @@ public function testGetMockForModelWithPlugin()
$TestPluginAuthors = $this->getMockForModel('TestPlugin.Authors', ['doSomething']);
$this->assertInstanceOf('TestPlugin\Model\Table\AuthorsTable', $TestPluginAuthors);
$this->assertEquals('TestPlugin\Model\Entity\Author', $TestPluginAuthors->getEntityClass());
Plugin::unload();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/TestCase/View/CellTest.php
Expand Up @@ -59,8 +59,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::unload('TestPlugin');
Plugin::unload('TestTheme');
Plugin::unload();
unset($this->View);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase/View/Helper/FlashHelperTest.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\Test\TestCase\View\Helper;

use Cake\Core\Plugin;
use Cake\Http\ServerRequest;
use Cake\Http\Session;
use Cake\TestSuite\TestCase;
Expand Down Expand Up @@ -105,6 +106,7 @@ public function tearDown()
{
parent::tearDown();
unset($this->View, $this->Flash);
Plugin::unload();
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/View/Helper/NumberHelperTest.php
Expand Up @@ -74,6 +74,7 @@ public function setUp()
public function tearDown()
{
parent::tearDown();
Plugin::unload();
static::setAppNamespace($this->_appNamespace);
unset($this->View);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/Helper/TextHelperTest.php
Expand Up @@ -142,7 +142,7 @@ public function testEngineOverride()
$this->loadPlugins('TestPlugin');
$Text = new TextHelperTestObject($this->View, ['engine' => 'TestPlugin.TestPluginEngine']);
$this->assertInstanceOf('TestPlugin\Utility\TestPluginEngine', $Text->engine());
Plugin::unload('TestPlugin');
Plugin::unload();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase/View/StringTemplateTest.php
Expand Up @@ -16,6 +16,7 @@

use Cake\TestSuite\TestCase;
use Cake\View\StringTemplate;
use Cake\Core\Plugin;

class StringTemplateTest extends TestCase
{
Expand Down Expand Up @@ -194,6 +195,7 @@ public function testLoadPlugin()
$this->loadPlugins('TestPlugin');
$this->assertNull($this->template->load('TestPlugin.test_templates'));
$this->assertEquals('<em>{{text}}</em>', $this->template->get('italic'));
Plugin::unload();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase/View/Widget/WidgetLocatorTest.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\Test\TestCase\View\Widget;

use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;
use Cake\View\StringTemplate;
use Cake\View\View;
Expand Down Expand Up @@ -98,6 +99,7 @@ public function testAddPluginWidgetsFromConfigInConstructor()
];
$inputs = new WidgetLocator($this->templates, $this->view, $widgets);
$this->assertInstanceOf('Cake\View\Widget\LabelWidget', $inputs->get('text'));
Plugin::unload();
}

/**
Expand Down

0 comments on commit e0f6112

Please sign in to comment.