Browse Source

unload() plugins after use

saeid 7 years ago
parent
commit
b2d58cf43e

+ 1 - 0
tests/TestCase/Auth/PasswordHasherFactoryTest.php

@@ -44,6 +44,7 @@ class PasswordHasherFactoryTest extends TestCase
         $this->loadPlugins('TestPlugin');
         $hasher = PasswordHasherFactory::build('TestPlugin.Legacy');
         $this->assertInstanceof('TestPlugin\Auth\LegacyPasswordHasher', $hasher);
+        Plugin::unload();
     }
 
     /**

+ 1 - 0
tests/TestCase/Command/HelpCommandTest.php

@@ -46,6 +46,7 @@ class HelpCommandTest extends ConsoleIntegrationTestCase
         $this->exec('help');
         $this->assertExitCode(Shell::CODE_SUCCESS);
         $this->assertCommandList();
+        Plugin::unload();
     }
 
     /**

+ 2 - 2
tests/TestCase/Console/CommandCollectionTest.php

@@ -256,8 +256,7 @@ class CommandCollectionTest extends TestCase
      */
     public function testDiscoverPlugin()
     {
-        $this->loadPlugins('TestPlugin');
-        $this->loadPlugins('Company/TestPluginThree');
+        $this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);
 
         $collection = new CommandCollection();
         // Add a dupe to test de-duping
@@ -297,5 +296,6 @@ class CommandCollectionTest extends TestCase
             'Long names are stored as well'
         );
         $this->assertSame($result['company'], $result['company/test_plugin_three.company']);
+        Plugin::unload();
     }
 }

+ 1 - 0
tests/TestCase/Console/HelperRegistryTest.php

@@ -127,5 +127,6 @@ class HelperRegistryTest extends TestCase
 
         $result = $this->helpers->loaded();
         $this->assertEquals(['SimpleAliased', 'SomeHelper'], $result, 'loaded() results are wrong.');
+        Plugin::unload();
     }
 }

+ 2 - 1
tests/TestCase/Console/ShellDispatcherTest.php

@@ -33,7 +33,7 @@ class ShellDispatcherTest extends TestCase
     public function setUp()
     {
         parent::setUp();
-        $this->loadPlugins('TestPlugin');
+        $this->loadPlugins(['TestPlugin', 'Company/TestPluginThree']);
         static::setAppNamespace();
         $this->dispatcher = $this->getMockBuilder('Cake\Console\ShellDispatcher')
             ->setMethods(['_stop'])
@@ -49,6 +49,7 @@ class ShellDispatcherTest extends TestCase
     {
         parent::tearDown();
         ShellDispatcher::resetAliases();
+        Plugin::unload();
     }
 
     /**

+ 2 - 0
tests/TestCase/Console/ShellTest.php

@@ -141,6 +141,7 @@ class ShellTest extends TestCase
             'TestPlugin\Model\Table\TestPluginCommentsTable',
             $this->Shell->TestPluginComments
         );
+        Plugin::unload();
     }
 
     /**
@@ -169,6 +170,7 @@ class ShellTest extends TestCase
             'TestPlugin\Model\Table\TestPluginCommentsTable',
             $this->Shell->TestPluginComments
         );
+        Plugin::unload();
     }
 
     /**

+ 1 - 0
tests/TestCase/Console/TaskRegistryTest.php

@@ -119,5 +119,6 @@ class TaskRegistryTest extends TestCase
 
         $result = $this->Tasks->loaded();
         $this->assertEquals(['CommandAliased', 'SomeTask'], $result, 'loaded() results are wrong.');
+        Plugin::unload();
     }
 }

+ 1 - 0
tests/TestCase/Controller/ComponentRegistryTest.php

@@ -54,6 +54,7 @@ class ComponentRegistryTest extends TestCase
     {
         parent::tearDown();
         unset($this->Components);
+        Plugin::unload();
     }
 
     /**

+ 2 - 0
tests/TestCase/Error/ErrorHandlerTest.php

@@ -15,6 +15,7 @@
 namespace Cake\Test\TestCase\Error;
 
 use Cake\Core\Configure;
+use Cake\Core\Plugin;
 use Cake\Error\ErrorHandler;
 use Cake\Error\PHP7ErrorException;
 use Cake\Http\Exception\ForbiddenException;
@@ -111,6 +112,7 @@ class ErrorHandlerTest extends TestCase
     {
         parent::tearDown();
         Log::reset();
+        Plugin::unload();
         if ($this->_restoreError) {
             restore_error_handler();
             restore_exception_handler();

+ 1 - 0
tests/TestCase/Error/ExceptionRendererTest.php

@@ -178,6 +178,7 @@ class ExceptionRendererTest extends TestCase
     public function tearDown()
     {
         parent::tearDown();
+        Plugin::unload();
         if ($this->_restoreError) {
             restore_error_handler();
         }

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

@@ -86,6 +86,7 @@ class SessionTest extends TestCase
     {
         unset($_SESSION);
         parent::tearDown();
+        Plugin::unload();
     }
 
     /**

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

@@ -1930,6 +1930,7 @@ class EmailTest extends TestCase
         $result = $this->Email->setTemplate('custom')->setLayout('TestPlugin.plug_default')->send();
         $this->assertContains('Here is your value: 12345', $result['message']);
         $this->assertContains('This email was sent using the TestPlugin.', $result['message']);
+        Plugin::unload();
     }
 
     /**

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

@@ -87,7 +87,7 @@ class HtmlHelperTest extends TestCase
     public function tearDown()
     {
         parent::tearDown();
-        Plugin::unload('TestTheme');
+        Plugin::unload();
         unset($this->Html, $this->View);
     }
 

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

@@ -607,7 +607,6 @@ class ViewTest extends TestCase
         $result = $View->getViewFileName('page.home');
         $this->assertPathEquals($expected, $result, 'Should not ruin files with dots.');
 
-        $this->loadPlugins('TestPlugin');
         $expected = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Pages' . DS . 'home.ctp';
         $result = $View->getViewFileName('TestPlugin.home');
         $this->assertPathEquals($expected, $result, 'Plugin is missing the view, cascade to app.');
@@ -730,7 +729,6 @@ class ViewTest extends TestCase
         ];
 
         $View = new TestView(null, null, null, $viewOptions);
-        $this->loadPlugins('TestPlugin');
 
         $expected = TEST_APP . 'Plugin' . DS . 'TestPlugin' . DS . 'src' . DS .
             'Template' . DS . 'Layout' . DS . 'default.ctp';