Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We need to be able to strict apply schema during configuration saves in particular tests.
This patch adds the ability to set a property on a test to enable this. It adds the property to TestBase and allows any KernelTestBase or WebTestBase to set this mode.
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @var bool
*/
protected $strictConfigSchema = FALSE;
Once enabled any configuration save that does not adhere to configuration schema will throw an exception.
This will help test issues like #2368349: Entity view and form display configuration schemas are too verbose / key ones missing
Comment | File | Size | Author |
---|---|---|---|
#10 | 2371843.10.patch | 16.38 KB | alexpott |
#10 | 7-10-interdiff.txt | 1.72 KB | alexpott |
#7 | 2371843.7.patch | 16.4 KB | alexpott |
#7 | 3-7-interdiff.txt | 9.19 KB | alexpott |
#3 | 2371843.3.patch | 12.14 KB | alexpott |
Comments
Comment #1
alexpottHere's an implementation. We have to put the event listener in core since a test might not have simpletest or config enabled.
Comment #2
effulgentsia CreditAttribution: effulgentsia commentedThat's not the main thing this method does. Also, could use an @throws.
A valid what?
Does this test have anything to do with traits? Same for the web test.
Nice comment. Could use one for the two other code blocks. Same for the web test.
Comment #3
alexpott@effulgentsia thank you the review
re #2
Comment #4
effulgentsia CreditAttribution: effulgentsia commentedThanks!
Comment #5
Wim LeersWhy not do this on every config save, rather than only during tests? That'd greatly improve DX. Is this really so slow? Do we have so many config writes?
Comment #6
Wim LeersOnly found silly nitpicks in review.
Namespace missing.
s/non existing/non-existing/
I don't know of Drupal using such shorthand variable names anywhere else.
<message>., <next>
looks weird (period followed by comma).Comment #7
alexpottAlso I realised one of the tests was wrong.
Comment #8
effulgentsia CreditAttribution: effulgentsia commentedComment #9
tstoecklerSorry for coming so late to this, but this breaks the
testing.services.yml
support introduced in #2229011: Tests are no longer modifiable. Specifically, the line that comes directly after the cutoff in the hunk above, copies the testing services file (if it exists) to$directory . '/services.yml'
, thus, it conflicts with the addition here. Both should be possible to have at the same time.Comment #10
alexpott@tstoeckler yep nice spot! Just moving the adding of the service should work without issue.
Comment #11
tstoecklerYes, that's very neat. I hadn't thought of that.
Comment #12
Wim LeersWhat about #5?
Follow-up, because we don't want to block this issue on that discussion?
Comment #13
alexpott@wim yep I will explore turning it on always in the general config schema issue. atm doing so would require us to fix all the schema in this issue.
Comment #14
Wim LeersD'oh, right, I think I've been told this in IRC already. Very much looking forward to getting instant feedback when a config entity (or config schema!) is wrong! :) That'll be a great DX improvement.
Comment #15
catchCommitted/pushed to 8.0.x, thanks!