Closed clarkwinkelmann closed 3 years ago
I like Solution 1. We should be able to set that to an empty array as an additional setup step, maybe?
The only challenge with solution 1 is that the code responsible for white-listing default extensions is part of our installation script for Flarum itself, separate from the tests setup. It's just called by the tests setup.
I've always thought we needed to make the whitelist of extensions configurable somehow, that would be useful for custom Flarum skeletons that could include other bundled extensions. The same configurable option in the installer could be used by the tests.
The only challenge with solution 1 is that the code responsible for white-listing default extensions is part of our installation script for Flarum itself, separate from the tests setup. It's just called by the tests setup.
I've always thought we needed to make the whitelist of extensions configurable somehow, that would be useful for custom Flarum skeletons that could include other bundled extensions. The same configurable option in the installer could be used by the tests.
We could use the const (https://github.com/flarum/core/blob/2536e495b3cbcb5b60403236188a8cca91386610/src/Install/Steps/EnableBundledExtensions.php#L69-L69) as a default option if no argument is provided (we'd need to add a null-default constructor argument to that step), and otherwise allow passing in a list (we'd need to add a new method to Installation
)?
The 2 PRs linked above close this issue.
Bug Report
Current Behavior Calling
$this->extension('kilowhat-formulaire')
in my integration tests causes the errorRuntimeException: Route tags.index on method GET already exists
. This is because when extensions are registered through$this->extension()
, Flarum runs all extenders for all extensions again. Since core extensions that might be installed are already marked enabled in the database as part of thesetup.php
script, they run both inExtensionServiceProvider
and again inOverrideExtensionManagerForTests
Steps to Reproduce
flarum/tags
as a dependency of the community extension$this->extension('community-extension')
in thesetUp
composer setup
composer test
Observe tests erroring with error
RuntimeException: Route tags.index on method GET already exists
.Expected Behavior See possible solutions.
Environment
Possible Solution Solution 1: we don't enable any core extension in the database level, so that
ExtensionServiceProvider
don't try running any extender, and require the developer to specify all extensions including core extensions they need inTestCase::extension()
Solution 2: in
OverrideExtensionManagerForTests
, don't run the extenders for extensions already enabled in the database. It's not easy because that class actually cannot control that, it just callsExtensionManager::extend()
A alternative to solution 2 would be to somehow make the change to enabled extensions before
ExtensionServiceProvider
runs, so that we don't need to run and extender insideOverrideExtensionManagerForTests
Additional Context Encountered with my Formulaire extension that depends on flarum/tags.