Postponed on #2395511: Config static cache is not cleared properly on rename and #2395515: Config static cache is not cleared properly on delete.
Problem/Motivation
In #2392319: Config objects (but not config entities) should by default be immutable we are making configuration be immutable by default. We found several bugs that way and hope to avoid more bugs in the future. It would be painful to need to pass FALSE to config() all the time in tests though so to make this simpler, we should introduce a config method on TestBase.
Proposed resolution
Introduce a config method on TestBase. Use that consistently in tests except when testing config with overrides specifically.
Remaining tasks
Do it. Review. Commit.
User interface changes
None.
API changes
TestBase will have a new config method to be used internally in tests.
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | 2395395-2.25.patch | 285.3 KB | alexpott |
| #25 | 22-25-interdiff.txt | 780 bytes | alexpott |
| #22 | interdiff.txt | 549 bytes | effulgentsia |
| #22 | 2395395.23.patch | 284.81 KB | effulgentsia |
| #21 | 2395395-20-review-do-not-test.patch | 8.46 KB | effulgentsia |
Comments
Comment #1
gábor hojtsyA quick patch. Added method with same code as ConfigFormBase::config() and used in tests.
Comment #2
alexpottRelating issues
Comment #3
alexpottWe should convert direct accesses to the config.factory get method too. For example the above code.
Perhaps we should have some documentation about how to get overridden configuration if you need to. I've thought about making the overridden-ness determined by a parameter but I think maybe that is overkill - if you need to work with overrides this should be documented and the test can use the config factory directly.
Comment #5
alexpottFIxed code so that tests will run and so that phpunit passes. This is blocked on #2395511: Config static cache is not cleared properly on rename (for sure -
Drupal\config\Tests\ConfigCRUDTestwill fail due to this bug) and maybe #2395515: Config static cache is not cleared properly on delete.Also given the plan outlined in #2392319-23: Config objects (but not config entities) should by default be immutable this issue might become implement
ConfigEdittableTraitas use it in tests.Comment #10
gábor hojtsyCritical due to #2392319-19: Config objects (but not config entities) should by default be immutable by @alexpott.
Comment #12
gábor hojtsyThese tests work with overrides so they need to access \Drupal::config() directly (or some other way we figure out):
- ConfigEventsTest: tests that overriden config passes into events
- ConfigExportUITest: tests that overrides are not exported but/and keep being in the system after export
- ConfigLanguageOverrideTest: tests how overrides apply
- ConfigOverrideTest: same
The rest of the tests seem to be some cache fail indeed and related actions after renaming and deleting config, so probably need to be postponed on #2395511: Config static cache is not cleared properly on rename and #2395515: Config static cache is not cleared properly on delete. But waiting for test feedback for now.
Comment #14
gábor hojtsyPostponing on #2395511: Config static cache is not cleared properly on rename and #2395515: Config static cache is not cleared properly on delete.
Comment #15
gábor hojtsyComment #16
alexpottBlockers have landed.
Comment #17
alexpottFixed tests failures from #12. I think this patch is good to go now. We might still have some problems in tests when implementing #2392319: Config objects (but not config entities) should by default be immutable but this should mean that we don't have to put the \Drupal::config and ConfigFactory::get() hacks to determine if being called from a test in.
As we can see only test code is changing so a green result should mean we are good to go here.
The patch needed a reroll - hence the pseudo interdiff.
Comment #18
gábor hojtsyI think this looks great, but not sure I would be eligible to RTBC due to prior significant work :/
Comment #19
effulgentsia commentedI'm still reviewing, but here's a reroll in the meantime.
Comment #20
effulgentsia commentedA few more conversions.
Comment #21
effulgentsia commentedMost of the 280K patch is straightforward conversions of
\Drupal::config()and$this->container->get('config.factory')->get()to$this->config()within tests.Here I'm attaching the hunks of the patch that are not that. This is the only part that could use a little more thorough human review.
Comment #22
effulgentsia commentedHow about we make it protected then? Done in this patch.
Other than that, I think this ready, but will wait for feedback on my interdiffs before RTBC'ing.
Comment #23
alexpott@effulgentsia nice finds and happy to see the method protected - not sure that this really matters since tests, but it's for the best. Would be really happy to see this get done quickly so we can proceed with discussions, investigations and patches on #2392319: Config objects (but not config entities) should by default be immutable.
Comment #24
effulgentsia commentedGreat!
Comment #25
alexpottA new one crept in in #2393577: Access issue with default settings set to disabled.
Comment #26
gábor hojtsyYay agreed with RTBC.
Comment #27
catchCommitted/pushed to 8.0.x, thanks!