- Issue created by @catch
- ๐ฌ๐งUnited Kingdom catch
From @alexpott:
You could do something like \Drupal\Core\Test\TestSetupTrait::$strictConfigSchema - just write the middleware directly to the services file and be doneโฆ and not use state at all.
- First commit to issue fork.
- ๐จ๐ญSwitzerland berdir Switzerland
I had a look at this, and that makes sense, I'm just not exactly sure how change it to that from where we are. The current trait sets state flag which I guess you can do anytime within the test. We could rebuild the container when the method is called and write the file then, but that seems complicated and requires reading, parsing and writing it again, or writing another file that we include?
That method currently needs to be called after setup obviously, while a new one would need to be called before to avoid extra rebuilds and complexity.
Maybe we should just deprecate the trait entirely in favor of a flag in the test base or a trait used there, like \Drupal\Core\Test\TestSetupTrait::$strictConfigSchema. For BC, we check if the trait is present and then do it to?
- ๐ฌ๐งUnited Kingdom catch
Could we set the flag in the same trait, deprecate the method (docs-only deprecation I guess to start with because it'll break tests if we @trigger_error), and use it like that?
- ๐จ๐ญSwitzerland berdir Switzerland
I think the logic for writing the services.yml file needs to be in \Drupal\Core\Test\FunctionalTestSetupTrait::prepareSettings, that's why my proposal is to deprecate the trait entirely and just have the flag there.
- Status changed to Postponed: needs info
about 1 month ago 3:59am 27 March 2025 - ๐ฆ๐บAustralia mstrelan
Apologies I didn't find this when I opened ๐ Move test middleware out of CoreServiceProvider Active . Wondering if this is still relevant? If we can avoid the container rebuild that would be ideal, but not sure if it's worth changing now.
- ๐ฌ๐งUnited Kingdom catch
For me I think ๐ Move test middleware out of CoreServiceProvider Active has improved this enough that we can probably close this one. I was mainly concerned about the extra database queries on every request.