8000 Loading plugin in tests throws already loaded error · Issue #17993 · cakephp/cakephp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Loading plugin in tests throws already loaded error #17993
Open
@ZoFem

Description

@ZoFem

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0