Open
Description
Description
If you used to load plugins in your tests, it now throws an error Possibly related to Cake\Core\Exception\CakeException: "Plugin named X is already loaded"
;
This is my code (in my controller test):
public function setUp(): void
{
parent::setUp();
$this->loadRoutes();
$this->loadPlugins(['X']);
}
In the migration guide it says:
- PluginCollection::addPlugin() now throws an exception if a plugin of the same name is already added.
- TestCase::loadPlugins() will now clear out any previously loaded plugins. So you must specify all plugins required for any subsequent tests.
So it seems the TestCase doesn't actually clear out previously loaded plugins. If I remove the newly added line in the PluginCollector in PluginCollection::addPlugin()
the errors go away.
I tried clearing the plugin manually like this:
$this->clearPlugins();
$this->removePlugins(['X']);
But that didn't work either.
CakePHP Version
5.1.1
PHP Version
8.2