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.
Problem/Motivation
The tests
core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php
both fail locally for me.
Testing Drupal\Tests\ckeditor5\Kernel\ValidatorsTest
..............W 15 / 15 (100%)
Time: 19.87 seconds, Memory: 10.00 MB
There was 1 warning:
1) Warning
The data provider specified for Drupal\Tests\ckeditor5\Kernel\ValidatorsTest::testPair is invalid.
Symfony\Component\Yaml\Exception\ParseException: File "profiles/standard/config/install/filter.format.restricted_html.yml" does not exist.
Testing Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest
....F.... 9 / 9 (100%)
Time: 12.66 seconds, Memory: 8.00 MB
There was 1 failure:
1) Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::test with data set "restricted_html can be switched to CKEditor 5 after dropping the two markup-creating filters (3 upgrade messages)" ('restricted_html', array(true, true), array(array(array('heading', 'bold', 'italic', '|', 'link', 'blockQuote', 'code', 'bulletedList', 'numberedList', 'sourceEditing')), array(array(array('heading2', 'heading3', 'heading4', 'heading5', 'heading6')), array(array('<cite>', '<dl>', '<dt>', '<dd>', '<a hreflang>', '<blockquote cite>', '<ul type>', '<ol start type>', '<h2 id>', '<h3 id>', '<h4 id>', '<h5 id>', '<h6 id>')))), '<br> <p>', array(array('CKEditor 5 only works with HT...ymore.', 'CKEditor 5 only works with HT...ymore.')), array('The following plugins were en...</em>.', 'The following tags were permi...d>.', 'This format's HTML filters in...d>.'), array('CKEditor 5 needs at least the...ilter.'))
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
Array &0 (
'' => Array &1 (
- 0 => 'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert URLs into links</em>" (<em class="placeholder">filter_url</em>) filter implies this text format is not HTML anymore.'
- 1 => 'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert line breaks into HTML (i.e. <code>&lt;br&gt;</code> and <code>&lt;p&gt;</code>)</em>" (<em class="placeholder">filter_autop</em>) filter implies this text format is not HTML anymore.'
+ 0 => 'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert line breaks into HTML (i.e. <code>&lt;br&gt;</code> and <code>&lt;p&gt;</code>)</em>" (<em class="placeholder">filter_autop</em>) filter implies this text format is not HTML anymore.'
+ 1 => 'CKEditor 5 only works with HTML-based text formats. The "<em class="placeholder">Convert URLs into links</em>" (<em class="placeholder">filter_url</em>) filter implies this text format is not HTML anymore.'
)
)
Steps to reproduce
Run the tests locally.
Proposed resolution
- Use a path relative to the test.
- Work out how to ensure a consistent order.
If I fix the path in ValidatorsTest then it fails for the same reason as SmartDefaultSettingsTest so going to fix both things here.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#9 | 3249240-8.patch | 8.29 KB | alexpott |
#9 | 4-8-interdiff.txt | 3.4 KB | alexpott |
#4 | 2-3-interdiff.txt | 5.23 KB | alexpott |
Comments
Comment #2
alexpottHere's the path fix... let's see what happens on DrupalCI.
Comment #3
andypostComment #4
alexpottGonna make this a critical. I think filter plugins must be validated in the correct order and I'm not sure that this happening at the moment. Whether this is the correct fix I'm not sure but at least now the order is determined by the sorting of filter plugins on a filter format.
Comment #5
andypostThank you for #2 it allows to start a test at least
Comment #6
andypost#4 works for me
Comment #7
andypostComment #8
andypostas it became visible on PHP 8.1 version
Comment #9
alexpott@andypost #4 definitely works but I think we need to decide whether it is the best fix. I think it is a bit odd that FilterFormat::filters() does not currently return sorted filters. If this is the correct fix then we need to has explicit test coverage of this.
Here's a more elegant fix that only makes changes to CkEditor5 module code. The plugin collection is correctly sorted - it's just that ->getAll() is not. Maybe we need to add followup for that but the docs for getAll() say:
Given it's intent to be exclusively used for the UI let's not use it here. We don't need to. We can yield the values we want from the iterator.
@andypost this has nothing to do with PHP 8.1 - it happens locally for me regardless of PHP version.
Comment #10
andypostThis approach looks better, just not sure about doc-blocks for
iteratable
++ to approach because this method is private and the code is new
it returns
$id => $entity
but doc-block mentions only entity interfaceComment #12
alexpott@andypost the phpdoc is inline with other generators in the codebase - for example:
And inline with people's thoughts on https://stackoverflow.com/questions/22272280/proper-phpdoc-comment-for-i...
Maybe you missed the
iterable|
at the beginning of @return.Comment #13
andypostOverlooked at late night, thank you for elaboration, then I guess it good to go
Comment #14
Wim LeersI'd like an opportunity to review before this goes in.
Comment #15
Wim Leers#2: no-brainer 👍
#4 seemed like a good improvement … but I agree that #9 is the more elegant solution, because the CKEditor 5 module seems to have been using
::getAll()
which surprisingly is apparently tightly coupled to a specific admin UI use case 😳All in all, this is a nice simplification! 🤩 I just wanted a chance to double-check because it sounded pretty scary 😅
P.S.: I can not reproduce the local failures though… I just run the tests using PHPStorm, which generates this command:
/usr/local/bin/php /private/var/folders/4l/5sndwsz50tqgxjh2525n10br0000gp/T/ide-phpunit.php --configuration /Users/wim.leers/Work/d8/core/phpunit.xml --filter Drupal\\Tests\\ckeditor5\\Kernel\\ValidatorsTest --test-suffix ValidatorsTest.php /Users/wim.leers/Work/d8/core/modules/ckeditor5/tests/src/Kernel
.Comment #18
lauriiiCommitted dc51481 and pushed to 9.4.x. Discussed with @alexpott and we agreed that this should be backported to 9.3.x. Thanks!