Browse Source

unload plugins after use

saeid 7 years ago
parent
commit
e0f6112f3f

+ 1 - 0
tests/TestCase/Http/SessionTest.php

@@ -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;

+ 1 - 0
tests/TestCase/Mailer/EmailTest.php

@@ -1763,6 +1763,7 @@ class EmailTest extends TestCase
         $this->assertContains('Message-ID: ', $result['headers']);
         $this->assertContains('To: ', $result['headers']);
         $this->assertContains('/test_theme/img/test.jpg', $result['message']);
+        Plugin::unload();
     }
 
     /**

+ 1 - 0
tests/TestCase/ORM/AssociationTest.php

@@ -470,6 +470,7 @@ class AssociationTest extends TestCase
         $this->assertSame('TestPlugin.ThisAssociationName', $table->getRegistryAlias());
         $this->assertSame('comments', $table->getTable());
         $this->assertSame('ThisAssociationName', $table->getAlias());
+        Plugin::unload();
     }
 
     /**

+ 11 - 0
tests/TestCase/ORM/Locator/TableLocatorTest.php

@@ -62,6 +62,17 @@ class TableLocatorTest extends TestCase
     }
 
     /**
+     * tearDown
+     *
+     * @return void
+     */
+    public function tearDown()
+    {
+        Plugin::unload();
+        parent::tearDown();
+    }
+
+    /**
      * Test config() method.
      *
      * @group deprecated

+ 1 - 0
tests/TestCase/ORM/QueryRegressionTest.php

@@ -545,6 +545,7 @@ class QueryRegressionTest extends TestCase
             $result->author->id,
             'No SQL error and author exists.'
         );
+        Plugin::unload();
     }
 
     /**

+ 1 - 0
tests/TestCase/ORM/ResultSetTest.php

@@ -397,6 +397,7 @@ class ResultSetTest extends TestCase
         })->first();
         $this->assertEquals('TestPlugin.Comments', $result->getSource());
         $this->assertEquals('TestPlugin.Authors', $result->_matchingData['Authors']->getSource());
+        Plugin::unload();
     }
 
     /**

+ 1 - 0
tests/TestCase/ORM/TableTest.php

@@ -128,6 +128,7 @@ class TableTest extends TestCase
     {
         parent::tearDown();
         $this->getTableLocator()->clear();
+        Plugin::unload();
     }
 
     /**

+ 12 - 2
tests/TestCase/Routing/Middleware/AssetMiddlewareTest.php

@@ -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();
     }
 
     /**

+ 1 - 0
tests/TestCase/Routing/RequestActionTraitTest.php

@@ -65,6 +65,7 @@ class RequestActionTraitTest extends TestCase
         parent::tearDown();
         DispatcherFactory::clear();
         Router::reload();
+        Plugin::unload();
 
         error_reporting($this->errorLevel);
     }

+ 1 - 1
tests/TestCase/Routing/RouteBuilderTest.php

@@ -49,7 +49,7 @@ class RouteBuilderTest extends TestCase
     public function tearDown()
     {
         parent::tearDown();
-        Plugin::unload('TestPlugin');
+        Plugin::unload();
     }
 
     /**

+ 1 - 1
tests/TestCase/Routing/RouterTest.php

@@ -356,7 +356,7 @@ class RouterTest extends TestCase
     public function testMapResourcesConnectOptions()
     {
         $this->deprecated(function () {
-            $this->loadPlugins('TestPlugin');
+            Plugin::load('TestPlugin');
             Router::mapResources('Posts', [
                 'connectOptions' => [
                     'routeClass' => 'TestPlugin.TestRoute',

+ 6 - 12
tests/TestCase/Shell/Task/AssetsTaskTest.php

@@ -67,8 +67,7 @@ class AssetsTaskTest extends TestCase
      */
     public function testSymlink()
     {
-        $this->loadPlugins('TestPlugin');
-        $this->loadPlugins('Company/TestPluginThree');
+        $this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);
 
         $this->Task->symlink();
 
@@ -157,8 +156,7 @@ class AssetsTaskTest extends TestCase
      */
     public function testSymlinkingSpecifiedPlugin()
     {
-        $this->loadPlugins('TestPlugin');
-        $this->loadPlugins('Company/TestPluginThree');
+        $this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);
 
         $this->Task->symlink('TestPlugin');
 
@@ -179,8 +177,7 @@ class AssetsTaskTest extends TestCase
      */
     public function testCopy()
     {
-        $this->loadPlugins('TestPlugin');
-        $this->loadPlugins('Company/TestPluginThree');
+        $this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);
 
         $this->Task->copy();
 
@@ -245,8 +242,7 @@ class AssetsTaskTest extends TestCase
             );
         }
 
-        $this->loadPlugins('TestPlugin');
-        $this->loadPlugins('Company/TestPluginThree');
+        $this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);
 
         mkdir(WWW_ROOT . 'company');
 
@@ -273,8 +269,7 @@ class AssetsTaskTest extends TestCase
      */
     public function testRemoveFolder()
     {
-        $this->loadPlugins('TestPlugin');
-        $this->loadPlugins('Company/TestPluginThree');
+        $this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);
 
         $this->Task->copy();
 
@@ -298,8 +293,7 @@ class AssetsTaskTest extends TestCase
      */
     public function testOverwrite()
     {
-        $this->loadPlugins('TestPlugin');
-        $this->loadPlugins('Company/TestPluginThree');
+        $this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);
 
         $path = WWW_ROOT . 'test_plugin';
 

+ 1 - 0
tests/TestCase/TestSuite/FixtureManagerTest.php

@@ -45,6 +45,7 @@ class FixtureManagerTest extends TestCase
     {
         parent::tearDown();
         Log::reset();
+        Plugin::unload();
     }
 
     /**

+ 1 - 0
tests/TestCase/TestSuite/TestCaseTest.php

@@ -465,6 +465,7 @@ class TestCaseTest extends TestCase
         $TestPluginAuthors = $this->getMockForModel('TestPlugin.Authors', ['doSomething']);
         $this->assertInstanceOf('TestPlugin\Model\Table\AuthorsTable', $TestPluginAuthors);
         $this->assertEquals('TestPlugin\Model\Entity\Author', $TestPluginAuthors->getEntityClass());
+        Plugin::unload();
     }
 
     /**

+ 1 - 2
tests/TestCase/View/CellTest.php

@@ -59,8 +59,7 @@ class CellTest extends TestCase
     public function tearDown()
     {
         parent::tearDown();
-        Plugin::unload('TestPlugin');
-        Plugin::unload('TestTheme');
+        Plugin::unload();
         unset($this->View);
     }
 

+ 2 - 0
tests/TestCase/View/Helper/FlashHelperTest.php

@@ -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;
@@ -105,6 +106,7 @@ class FlashHelperTest extends TestCase
     {
         parent::tearDown();
         unset($this->View, $this->Flash);
+        Plugin::unload();
     }
 
     /**

+ 1 - 0
tests/TestCase/View/Helper/NumberHelperTest.php

@@ -74,6 +74,7 @@ class NumberHelperTest extends TestCase
     public function tearDown()
     {
         parent::tearDown();
+        Plugin::unload();
         static::setAppNamespace($this->_appNamespace);
         unset($this->View);
     }

+ 1 - 1
tests/TestCase/View/Helper/TextHelperTest.php

@@ -142,7 +142,7 @@ class TextHelperTest extends TestCase
         $this->loadPlugins('TestPlugin');
         $Text = new TextHelperTestObject($this->View, ['engine' => 'TestPlugin.TestPluginEngine']);
         $this->assertInstanceOf('TestPlugin\Utility\TestPluginEngine', $Text->engine());
-        Plugin::unload('TestPlugin');
+        Plugin::unload();
     }
 
     /**

+ 2 - 0
tests/TestCase/View/StringTemplateTest.php

@@ -16,6 +16,7 @@ namespace Cake\Test\TestCase\View;
 
 use Cake\TestSuite\TestCase;
 use Cake\View\StringTemplate;
+use Cake\Core\Plugin;
 
 class StringTemplateTest extends TestCase
 {
@@ -194,6 +195,7 @@ class StringTemplateTest extends TestCase
         $this->loadPlugins('TestPlugin');
         $this->assertNull($this->template->load('TestPlugin.test_templates'));
         $this->assertEquals('<em>{{text}}</em>', $this->template->get('italic'));
+        Plugin::unload();
     }
 
     /**

+ 2 - 0
tests/TestCase/View/Widget/WidgetLocatorTest.php

@@ -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;
@@ -98,6 +99,7 @@ class WidgetLocatorTestCase extends TestCase
         ];
         $inputs = new WidgetLocator($this->templates, $this->view, $widgets);
         $this->assertInstanceOf('Cake\View\Widget\LabelWidget', $inputs->get('text'));
+        Plugin::unload();
     }
 
     /**