- Issue was unassigned.
- Status changed to Needs review
almost 2 years ago 9:35pm 19 January 2023 - Status changed to RTBC
almost 2 years ago 2:23pm 23 January 2023 - 🇬🇧United Kingdom longwave UK
Looks great - one nitpick that could go either way:
+++ b/core/modules/field/tests/src/Kernel/EntityReference/Views/SelectionTest.php @@ -132,7 +133,10 @@ public function testSelectionHandler() { + $subresults_formatted = array_map(function (MarkupInterface $markup): string { + return (string) $markup; + }, $subresults); + $filtered_rendered_results_formatted += $subresults_formatted;
I think it's somewhat less verbose to just use
strval()
?$filtered_rendered_results_formatted += array_map('strval', $subresults_formatted);
or if you want to be more strictly typed
$filtered_rendered_results_formatted += array_map(fn(MarkupInterface $markup) => (string) $markup, $subresults_formatted);
- 🇬🇧United Kingdom longwave UK
...so while this solves the issue of assertEquals() comparing markup, it no longer solves the actual issue of removing
t()
inassertEquals()
- there are a whole bunch of cases left:$ rg 'assertEquals.*\Wt\('|sort core/modules/contact/tests/src/Functional/ContactSitewideTest.php: $this->assertEquals(t('[@label] @subject', ['@label' => $label, '@subject' => $edit['subject[0][value]']]), $mail['subject']); core/modules/field/tests/src/Kernel/FieldCrudTest.php: $this->assertEquals(t('%name does not accept the value @value.', ['%name' => $field_name, '@value' => -2]), $violations[0]->getMessage()); core/modules/field/tests/src/Kernel/FieldCrudTest.php: $this->assertEquals(t('This value should be between %min and %max.', ['%min' => 0, '%max' => 32]), $violations[0]->getMessage()); core/modules/field/tests/src/Kernel/FieldCrudTest.php: $this->assertEquals(t('This value should be between %min and %max.', ['%min' => 0, '%max' => 32]), $violations[1]->getMessage()); core/modules/field/tests/src/Kernel/FieldValidationTest.php: $this->assertEquals(t('%name: this field cannot hold more than @count values.', ['%name' => $this->fieldTestData->field->getLabel(), '@count' => $cardinality]), $violations[0]->getMessage()); core/modules/file/tests/src/Kernel/SaveTest.php: $this->assertEquals(t('The file %value already exists. Enter a unique file URI.', ['%value' => $uppercase_file_duplicate->getFileUri()]), $violations[0]->getMessage()); core/modules/forum/tests/src/Kernel/ForumValidationTest.php: $this->assertEquals(t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', ['%forum' => $container->label()]), $violations[0]->getMessage()); ...
- 🇺🇸United States xjm
So the title and IS don't seem to be describing what's actually being done in this issue.
The scope of the parent meta was intended to be removing unnecessary direct uses of
t()
and friends in test fixture data. However, this issue's primary scope seems to be that of convertingassertEquals()
calls toassertSame()
(and therefore adding a string cast on passed-in markup objects, wheret()
is already not called directly in the assertions).If the goal is to remove use of
assertEquals()
with translatable strings and markup objects, then the IS should be completely rewritten and the issue retitled.Thanks for working on this!
- Status changed to Needs work
almost 2 years ago 3:23pm 23 January 2023 - 🇺🇸United States smustgrave
With such a large number of changes would it make sense to breakup?
- 🇬🇧United Kingdom longwave UK
I don't think it can be broken up easily but we might want to spin off a child issue for the changes to
MarkupInterfaceComparator
and then come back here to fix theassertEquals()
calls. - Status changed to Needs review
almost 2 years ago 3:35pm 23 January 2023 - Status changed to Needs work
almost 2 years ago 4:22pm 23 January 2023 - 🇬🇧United Kingdom longwave UK
Opened 📌 Remove remaining uses of t() in assertEquals() calls Fixed to handle the remainder, and retitled and updated the IS of this issue.
The change record still needs work.
- Status changed to Needs review
almost 2 years ago 2:55pm 2 February 2023 - Status changed to RTBC
almost 2 years ago 5:38pm 2 February 2023 - 🇺🇸United States smustgrave
Reviewed the change record and looks great. The examples were super helpful
- 🇬🇧United Kingdom longwave UK
RTBC +1, the change record is nice and clear to me.
-
longwave →
committed c187cc63 on 10.1.x
Issue #3153468 by mondrake, mohrerao, mallezie, smustgrave, meena.bisht...
-
longwave →
committed c187cc63 on 10.1.x
- Status changed to Fixed
almost 2 years ago 2:50pm 7 February 2023 - 🇬🇧United Kingdom longwave UK
Committed and pushed c187cc6339 to 10.1.x. Thanks!
Automatically closed - issue fixed for 2 weeks with no activity.