- 🇳🇿New Zealand quietone
Tagging for coding standards and moving to the 'other' component where such issues live.
- 🇬🇧United Kingdom longwave UK
📌 Remove remaining uses of t() in assertEquals() calls Fixed landed.
I think we are down to the final few stragglers, opened 📌 Remove remaining unnecessary uses of t() in tests Active to cover those.
I also am leaning towards closing 📌 Remove uses of t() in setLabel() and setDescription() calls Needs work as won't fix as we are effectively testing that APIs can receive TranslatableMarkup, as they would outside of tests.
- 🇳🇿New Zealand quietone
And the number of instances has risen since #30.
$ find core -type f -iname '*Test.php' | xargs grep '[^a-zA-Z]t(' | wc -l 274
- 🇳🇿New Zealand quietone
Trying to confirm that this is done, since 📌 Remove remaining unnecessary uses of t() in tests Active has been committed. I searched Test files using the grep in that issue and ignored all the files listed in that IS that are valid uses of t(). Then ignored the tests in package_manager because which isn't testing translations but tests validation messages where the methods have a type hint for TranslatableMarkup. That left 16 files with 26 instances of t() that need to be checked.
- core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php
- core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
- core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
- core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
- core/modules/migrate/tests/modules/migrate_high_water_test/src/Plugin/migrate/source/HighWaterTest.php
- core/modules/migrate/tests/src/Kernel/MigrateEntityContentValidationTest.php
- core/modules/navigation/tests/src/Functional/NavigationLogoTest.php
- core/modules/navigation/tests/src/Unit/TopBarItemManagerTest.php
- core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
- core/modules/system/tests/src/Kernel/System/RunTimeRequirementsTest.php
- core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php
- core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php
- core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php
- core/tests/Drupal/KernelTests/Core/Updater/UpdateRequirementsTest.php
- core/tests/Drupal/KernelTests/Core/Url/LinkGenerationTest.php
- core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php
- 🇳🇿New Zealand quietone
Of those, 13, is testing translations. The rest includes some that were missed in 📌 Remove remaining unnecessary uses of t() in tests Active and others from commits made this month. There is nothing to prevent added other unnecessary uses of t() in tests so lets' fix this last group and stop chasing new introduced cases. Right now, we can only rely on review to prevent the addition of more unnecessary uses of t() in tests.
- 🇳🇿New Zealand quietone
Here is the script I used for finding usages of t() in tests.
- 🇳🇿New Zealand quietone
Postponing until the issues to fix "DrupalPractice.Objects.GlobalFunction" in tests is complete. 📌 [META] Replace t() calls inside of classes Active
- 🇺🇸United States smustgrave
Used the script provided and believe all instances have been found.
- 🇬🇧United Kingdom catch
This appears to be removing one assertion entirely instead of updating it to not use t().
- Status changed to Fixed
29 days ago 2:54pm 8 March 2025 Automatically closed - issue fixed for 2 weeks with no activity.