PluginTestCase Question #1148
Replies: 1 comment
-
It's assumed that when writing tests for plugins, their functionality should be self contained, i.e. all tests for Sometimes life isn't straight forward, so in that case it is possible to boot multiple plugins but it is a bit more complex than by default. If you look here: public function setUp(): void
{
// Reload the plugin and update manager singletons
PluginManager::forgetInstance();
UpdateManager::forgetInstance();
parent::setUp();
// Run all migrations
Artisan::call('winter:up');
// Reset loaded plugins for this test
$this->pluginTestCaseLoadedPlugins = [];
// Detect the plugin being tested and load it automatically
$pluginCode = $this->guessPluginCode();
if (!is_null($pluginCode)) {
$this->instantiatePlugin($pluginCode, false);
}
// Disable mailing
Mail::pretend();
} What happens is all plugins are removed After this step, all "testing" plugins are loaded, these are supplied from the framework and are used for testing framework features. Next, the following is called: $pluginCode = $this->guessPluginCode();
if (!is_null($pluginCode)) {
$this->instantiatePlugin($pluginCode, false);
} Which loads the plugin your test is written for (by guessing from the namespace). If you wanted to change this behaviour, you can extend the default public function setUp(): void
{
parent::setUp();
$this->instantiatePlugin('Author.Plugin1', false);
$this->instantiatePlugin('Author.Plugin2', false);
} Which should force the To see what plugins are loaded, you could temporarily add a test such as the following: public function testExample(): void
{
dd(PluginManager::instance()->getPlugins());
} |
Beta Was this translation helpful? Give feedback.
-
When running a test which extends PluginTestCase does it boot...
ALL installed plugins or ?
only the plugin which the current tests resides inside or ?
The plugin which the current tests resides inside and its dependencies ( and of course their dependencies )?
Is there any way to change this behaviour?
Is there any way to see a list of booted plugins?
Beta Was this translation helpful? Give feedback.
All reactions