Problem/Motivation
\Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase::assertValidationErrors() was introduced in #3324150: Add validation constraints to config_entity.dependencies and currently just asserts an array of actual violation messages/validation error messages.
It'd be better to instead assert them based on the property path at which that validation error occurred, to avoid false positives. That's also what \Drupal\Tests\ckeditor5\Kernel\CKEditor5ValidationTestTrait::validatePairToViolationsArray() does.
Discovered this while working on #3341682: New config schema data type: `required_label`.
Steps to reproduce
N/A
Proposed resolution
Improve it!
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3349293-14.patch | 11.13 KB | wim leers |
Issue fork drupal-3349293
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wim leersComment #4
wim leersComment #5
phenaproximaI like this. Once tests pass I see no real reason not to RTBC it. IMHO it might also make sense for the base class to always assert that property paths are passed as the keys, just so it's not possible to write a test that doesn't include the property paths.
Comment #6
wim leersGlad you like it!
True, but the
assertSame()will make it crystal clear anyway, so I don't see the benefit of making test logic more complicated if it result in almost identical DX :)Comment #7
smustgrave commentedMarking it but only question is what if contrib modules are using ConfigEntityValidationTestBase. Will they now fail?
Comment #8
wim leersIt has only existed in
10.1.xso hasn't shipped in any release at all yet — stable or otherwise! See #3324150: Add validation constraints to config_entity.dependencies :)Comment #9
longwaveI agree with @quietone, we should document what the keys and values mean in the array.
Comment #10
wim leersGood call! 😊 Done.
I took advantage of #3358739: Update coder to 8.3.18 having landed a few days ago. That got Drupal core on https://www.drupal.org/project/coder/releases/8.3.18, which includes #3253472: Support advanced PHPStan data types (general, arrays).
That means it's now far easier to clearly convey that key-value pairs are expected, and what the type should be of the keys vs the values.
Comment #11
borisson_This documentation looks great!
Comment #13
bnjmnmA low stakes back to NW.
Left two comments on the MR (one on an existing thread) that are simple enough that it would be fine to self-rtbc once addressed.
Comment #14
wim leersGreat catch, @bnjmnm! 😄
Tried to create an
11.xbranch, and failed:Failed to create branch '3349293-improve-ConfigEntityValidationTestBase-assertValidationErrors-11x': invalid reference name '11.x'.So continuing to push to the
10.1.xMR and posting a patch to test against11.x.Comment #15
wim leersAlso, this literally just came up at #3364109-7: Configuration schema & required values: add test coverage for `nullable: true` validation support!
See the test output at https://www.drupal.org/pift-ci-job/2681594:
not very helpful, right? 😳 This fixes that:
👍
Comment #16
wim leersThe failure on
10.1.xis a random fail inDrupal\FunctionalJavascriptTests\Ajax\ThrobberTest.#14 is green on
11.x👍Comment #19
bnjmnmGood stuff here 😎.
Committed to 11.x and cherry-picked to 10.1.x.
🏄♀️
Comment #20
bnjmnmComment #22
wim leersThank you! 🙏😊