- Issue created by @dww
- πΊπΈUnited States dww
Ugh, sorry, I thought I'd be able to delete empty branches when I had typos in the names. π¬ Whoops.
Opened an MR on the branch that I intended to create:
3402293-kernel-module-tests-simple-formattablemarkup-to-string
π - Merge request !5444Draft: Resolve #3402293 "Kernel module tests simple formattablemarkup to string" β (Open) created by dww
- First commit to issue fork.
- Status changed to Needs review
about 1 year ago 1:50am 20 November 2023 - π¦πΊAustralia mstrelan
@dww not sure I can change your draft to not draft
- Status changed to Needs work
about 1 year ago 1:07pm 20 November 2023 - πΊπΈUnited States smustgrave
Using
grep -r -n 'FormattableMarkup(' core/modules/*/tests/src/Kernel/*
I get some more hits after applying the MRcore/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php:236: $this->assertTrue($may_view, new FormattableMarkup('User @user can view field @field on comment @comment', [ core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php:241: $this->assertEquals($may_update, $set['user']->hasPermission('administer comments'), new FormattableMarkup('User @user @state update field @field on comment @comment', [ core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php:253: $this->assertEquals($may_update, $set['user']->hasPermission('administer comments') || ($set['user']->hasPermission('edit own comments') && $set['user']->id() == $set['comment']->getOwnerId()), new FormattableMarkup('User @user @state update field subject on comment @comment', [ core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php:275: $this->assertEquals($may_view, $view_access, new FormattableMarkup('User @user @state view field @field on comment @comment', [ core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php:281: $this->assertFalse($may_update, new FormattableMarkup('User @user @state update field @field on comment @comment', [ core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php:296: $this->assertTrue($may_view, new FormattableMarkup('User @user can view field @field on comment @comment', [ core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php:302: $this->assertEquals($expected, $may_update, new FormattableMarkup('User @user @state update field @field on comment @comment', [ core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php:324: ), new FormattableMarkup('User @user @state update field @field on comment @comment', [ core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php:68: $this->assertEquals(new FormattableMarkup($entry['message'], $message_vars), $view->style_plugin->getField($index, 'message')); core/modules/field/tests/src/Kernel/DisplayApiTest.php:146: $this->assertText($setting . '|' . $value['value'], new FormattableMarkup('Value @delta was displayed with expected setting.', ['@delta' => $delta])); core/modules/field/tests/src/Kernel/DisplayApiTest.php:205: $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), new FormattableMarkup('Value @delta was displayed with expected setting.', ['@delta' => $delta])); core/modules/field/tests/src/Kernel/DisplayApiTest.php:215: $this->assertText($setting . '|' . $value['value'], new FormattableMarkup('Value @delta was displayed with expected setting.', ['@delta' => $delta])); core/modules/field/tests/src/Kernel/DisplayApiTest.php:225: $this->assertText($setting . '|' . $value['value'], new FormattableMarkup('Value @delta was displayed with expected setting.', ['@delta' => $delta])); core/modules/field/tests/src/Kernel/DisplayApiTest.php:240: $this->assertText($setting . '|' . $value['value'], new FormattableMarkup('Value @delta was displayed with expected setting.', ['@delta' => $delta])); core/modules/field/tests/src/Kernel/DisplayApiTest.php:255: $this->assertText($setting . '|0:' . $value['value'], new FormattableMarkup('Value @delta was displayed with expected setting.', ['@delta' => $delta])); core/modules/field/tests/src/Kernel/DisplayApiTest.php:270: $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), new FormattableMarkup('Value @delta was displayed with expected setting.', ['@delta' => $delta])); core/modules/field/tests/src/Kernel/DisplayApiTest.php:279: $this->assertText($setting . '|' . $value['value'], new FormattableMarkup('Value @delta was displayed with expected setting.', ['@delta' => $delta])); core/modules/field/tests/src/Kernel/DisplayApiTest.php:289: $this->assertText($setting . '|' . $value['value'], new FormattableMarkup('Value @delta was displayed with expected setting.', ['@delta' => $delta])); core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php:461: $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'node', '%label' => $title]), $errors[0]->getMessage()); core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php:509: $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'node', '%label' => $unsaved_unpublished_node_title]), $errors[0]->getMessage()); core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php:511: $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'node', '%label' => $saved_unpublished_node->id()]), $errors[1]->getMessage()); core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php:519: $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'node', '%label' => $unsaved_unpublished_node_title]), $errors[0]->getMessage()); core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php:543: $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'comment', '%label' => $title]), $errors[0]->getMessage()); core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php:566: $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'user', '%label' => $name]), $errors[0]->getMessage()); core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php:589: $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'file', '%label' => $filename]), $errors[0]->getMessage()); core/modules/field/tests/src/Kernel/FieldKernelTestBase.php:215: $this->assertEquals($value, $values[$key][$column], new FormattableMarkup('Value @value was saved correctly.', ['@value' => $value])); core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php:165: $expected = new FormattableMarkup($past_format, ['@interval' => \Drupal::service('date.formatter')->formatTimeDiffSince($value, ['granularity' => $granularity])]); core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php:180: $expected = new FormattableMarkup($future_format, ['@interval' => \Drupal::service('date.formatter')->formatTimeDiffUntil($value, ['granularity' => $granularity])]); core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php:707: $message = $assertion ? new FormattableMarkup("@context display '@id' depends on @type '@key'.", $args) : new FormattableMarkup("@context display '@id' do not depend on @type '@key'.", $args); core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php:60: $this->assertTrue(FALSE, new FormattableMarkup('Expected hooks %expected to be called but %uncalled was not called.', ['%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)])); core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php:63: $this->assertTrue(TRUE, new FormattableMarkup('All the expected hooks were called: %expected', ['%expected' => empty($expected) ? '(none)' : implode(', ', $expected)])); core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php:69: $this->assertTrue(FALSE, new FormattableMarkup('Unexpected hooks were called: %unexpected.', ['%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected)])); core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php:91: $message = new FormattableMarkup('hook_file_@name was called correctly.', ['@name' => $hook]); core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php:97: $message = new FormattableMarkup('hook_file_@name was expected to be called %expected times but was called %actual times.', ['@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count]); core/modules/file/tests/src/Kernel/MoveTest.php:60: $this->assertEquals($source->id(), $result->id(), new FormattableMarkup("Source file id's' %fid is unchanged after move.", ['%fid' => $source->id()])); core/modules/filter/tests/src/Kernel/FilterKernelTest.php:932: $this->assertStringContainsString($value, $result, new FormattableMarkup('@source: @value found. Filtered result: @result.', [ core/modules/filter/tests/src/Kernel/FilterKernelTest.php:939: $this->assertStringNotContainsString($value, $result, new FormattableMarkup('@source: @value not found. Filtered result: @result.', [ core/modules/filter/tests/src/Kernel/FilterKernelTest.php:1116: $this->assertEquals($html, Html::normalize($html), new FormattableMarkup('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '/*<![CDATA[*/'])); core/modules/filter/tests/src/Kernel/FilterKernelTest.php:1124: $this->assertEquals($html, Html::normalize($html), new FormattableMarkup('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '<!--/*--><![CDATA[/* ><!--*/'])); core/modules/filter/tests/src/Kernel/FilterKernelTest.php:1131: $this->assertEquals($html, Html::normalize($html), new FormattableMarkup('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '<!--//--><![CDATA[// ><!--'])); core/modules/filter/tests/src/Kernel/FilterKernelTest.php:1138: $this->assertEquals($html, Html::normalize($html), new FormattableMarkup('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '// <![CDATA['])); core/modules/filter/tests/src/Kernel/FilterKernelTest.php:1145: $this->assertEquals($html, Html::normalize($html), new FormattableMarkup('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '// <![CDATA[![CDATA[![CDATA['])); core/modules/filter/tests/src/Kernel/FilterKernelTest.php:1153: $this->assertEquals($html, Html::normalize(Html::normalize($html)), new FormattableMarkup('HTML corrector -- Existing cdata section @pattern_name properly escaped', ['@pattern_name' => '// <![CDATA[![CDATA[![CDATA['])); core/modules/menu_link_content/tests/src/Kernel/MenuLinksTest.php:132: $this->assertEquals($expected_parent, $menu_link_plugin->getParent(), new FormattableMarkup('Menu link %id has parent of %parent, expected %expected_parent.', ['%id' => $id, '%parent' => $menu_link_plugin->getParent(), '%expected_parent' => $expected_parent])); core/modules/node/tests/src/Kernel/NodeAccessTestBase.php:140: return new FormattableMarkup( core/modules/system/tests/src/Kernel/Common/SystemListingTest.php:49: $this->assertEquals($expected_uri, $files[$module]->getPathname(), new FormattableMarkup('Module @actual was found at @expected.', ['@actual' => $files[$module]->getPathname(), '@expected' => $expected_uri])); core/modules/system/tests/src/Kernel/Common/FormElementsRenderTest.php:151: $this->assertFieldByXPath($xpath, $element['#value'], new FormattableMarkup('#type @type was properly rendered.', [ core/modules/system/tests/src/Kernel/Form/ProgrammaticTest.php:80: $this->assertSame($valid_form, $valid_input, new FormattableMarkup('Input values: %values<br />Validation handler errors: %errors', $args)); core/modules/system/tests/src/Kernel/Form/ProgrammaticTest.php:87: $this->assertEquals($value, $stored_values[$key], new FormattableMarkup('Submission handler correctly executed: %stored_key is %stored_value', ['%stored_key' => $key, '%stored_value' => print_r($value, TRUE)])); core/modules/system/tests/src/Kernel/Theme/FunctionsTest.php:209: 'title' => new FormattableMarkup('<span class="unescaped">@text</span>', ['@text' => 'potentially unsafe text that <should> be escaped']), core/modules/system/tests/src/Kernel/Theme/FunctionsTest.php:330: 'title' => new FormattableMarkup('<span class="unescaped">@text</span>', ['@text' => 'potentially unsafe text that <should> be escaped']), core/modules/taxonomy/tests/src/Kernel/TermValidationTest.php:62: $this->assertEquals(new FormattableMarkup('The referenced entity (%type: %id) does not exist.', ['%type' => 'taxonomy_term', '%id' => 9999]), $violations[0]->getMessage()); core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php:149: $this->assertEquals(new FormattableMarkup('The user is a member of @roles', ['@roles' => $this->role->label()]), $condition->summary()); core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php:290: $this->assertEquals($expected_output_0, $output, new FormattableMarkup('Test token replacement: "@token" gave "@output"', ['@token' => $name_field_0->options['alter']['text'], '@output' => $output])); core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php:295: $this->assertEquals($expected_output_1, $output, new FormattableMarkup('Test token replacement: "@token" gave "@output"', ['@token' => $name_field_1->options['alter']['text'], '@output' => $output])); core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php:300: $this->assertEquals($expected_output_2, $output, new FormattableMarkup('Test token replacement: "@token" gave "@output"', ['@token' => $name_field_2->options['alter']['text'], '@output' => $output])); core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php:312: $this->assertSubString($output, $random_text, new FormattableMarkup('Make sure the self token (@token => @value) appears in the output (@output)', [ core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php:326: $this->assertEquals($old_token, $output, new FormattableMarkup('Make sure the old token style (@token => @value) is not changed in the output (@output)', ['@value' => $random_text, '@output' => $output, '@token' => $job_field->options['alter']['text']])); core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php:355: $this->assertEquals($random_text, $output, new FormattableMarkup('Make sure a script tag in the template (@template) is removed, leaving only the replaced token in the output (@output)', ['@output' => $output, '@template' => $rewrite_template])); core/modules/views/tests/src/Kernel/Handler/SortDateTest.php:205: ], new FormattableMarkup('Result is returned correctly when ordering by granularity @granularity, @reverse.', ['@granularity' => $granularity, '@reverse' => $reverse ? 'reverse' : 'forward'])); core/modules/views/tests/src/Kernel/ModuleTest.php:81: $details[] = new FormattableMarkup('@key: @value', ['@key' => $key, '@value' => $value]);
- Status changed to Needs review
about 1 year ago 1:15pm 20 November 2023 - π¦πΊAustralia mstrelan
Can you confirm if those are covered by the other issues in the meta? The approach I took to verify what was left was to take the original branch then git apply --reverse each of these patches, then diff with 11.x. The only changes outstanding were changing existing sprintf calls which should probably be out of scope.
- πΊπΈUnited States smustgrave
I don't see another Formatter ticket for the core/modules directly
- π¦πΊAustralia mstrelan
Should be these two
π Fix strict type errors: Convert FormattableMarkup to strings (complex replacement) in core Kernel tests Active
π Fix strict type errors in CommentFieldAccessTest Active - Status changed to RTBC
about 1 year ago 1:52pm 20 November 2023 -
longwave β
committed d39fc225 on 10.2.x
Issue #3402293 by dww, mstrelan, smustgrave: Fix strict type errors:...
-
longwave β
committed d39fc225 on 10.2.x
-
longwave β
committed df70716e on 11.x
Issue #3402293 by dww, mstrelan, smustgrave: Fix strict type errors:...
-
longwave β
committed df70716e on 11.x
- Status changed to Fixed
about 1 year ago 11:43am 25 November 2023 - π¬π§United Kingdom longwave UK
Reviewed with
git diff --color-words
and everything looks fine. The messages not inside loops could probably even be removed as there is usually enough context to figure out the problem from the assertion failure alone, but instead of bikeshedding that here I think just removingFormattableMarkup
is the best approach. The scope is just right as well; not too small to end up with lots of issues, but not too big to be unreviewable.Backported to 10.2.x as a tests-only change. Also eligible for 10.1.x but did not cherry pick cleanly, not worth the effort of rerolling it now.
Committed and pushed df70716e5a to 11.x and d39fc2255a to 10.2.x. Thanks!
- πΊπΈUnited States dww
Slick! β¨ Allow hiding issue fork branches Fixed is now done, deployed and working. π
Automatically closed - issue fixed for 2 weeks with no activity.