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.
While we removed most t()
calls from our tests back in #2832015: Remove translations from functional tests, it seems a few got overlooked back then, or were added in later issues.
To find them: git grep '\bt(' `find -type d -name tests`
Comment | File | Size | Author |
---|---|---|---|
#13 | remove_translations_from_all_tests-2870988-13.patch | 10.22 KB | kala4ek |
| |||
#11 | remove_translations_from_all_tests-2870988-11.patch | 3.91 KB | c.nish2k3 |
| |||
#8 | remove_translations_from_all_tests-2870988-8.patch | 3.87 KB | c.nish2k3 |
#4 | Iss-2870988-remove_translations_from_all_tests.patch | 717 bytes | sahilsharma011 |
|
Comments
Comment #2
drunken monkeyComment #3
sahilsharma011 CreditAttribution: sahilsharma011 at Google Summer of Code commentedI'll work on a patch.
Comment #4
sahilsharma011 CreditAttribution: sahilsharma011 at Google Summer of Code commentedPatch provided. Please review.
Comment #5
rodrigoac CreditAttribution: rodrigoac at CI&T commentedHi people,
I am not sure if this is right, but we need to remove all usages of t() in tests ?
If yes, and after I ran 'git grep' this is the output:
$ git grep '\bt(' `find -type d -name tests` tests/search_api_test
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->drupalPostForm('admin/modules', $edit_enable, t('Install'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->assertSession()->pageTextContains(t('Some required modules must be enabled'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->drupalPostForm(NULL, [], t('Continue'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->drupalPostForm('node/add/article', $edit, $this->t('Save and publish'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->drupalPostForm('admin/modules/uninstall', $edit_disable, t('Uninstall'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->submitForm([], t('Uninstall'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$submit = $tab == 'fields' ? $this->t('Save changes') : $this->t('Save');
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->drupalPostForm('admin/modules', $edit_enable, t('Install'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->assertSession()->pageTextContains(t('It looks like the default setup provided by this module already exists on your site. Cannot re-install module.'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->submitForm([], $this->t('Delete'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->clickLink(t('Delete'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->submitForm([], t('Delete'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$this->drupalPostForm('admin/modules', $edit_enable, t('Install'));
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php:
$success_text = t('Content type @content_type not found. Database Search Defaults module could not be installed.', ['@content_type' => 'article']);
modules/search_api_db/tests/src/FunctionalJavascript/IntegrationTest.php:
$this->submitForm($edit, $this->t('Save'));
modules/search_api_db/tests/src/Kernel/BackendTest.php:
$this->assertResults([1, 2, 3], $results, 'Search for »foo«', ['foo'], [$this->t('No valid search keys were present in the query.')]);
tests/search_api_test/src/Plugin/search_api/backend/TestBackend.php:
'#title' => $this->t('Test'),
tests/search_api_test_hooks/search_api_test_hooks.search_api.inc:
$displays['views_page:search_api_test_view__page_1']['label'] = t('Some funny label for testing');
tests/src/Functional/IntegrationTest.php:
$this->assertSession()->pageTextNotContains(t('The listed configuration will be deleted.'));
tests/src/Functional/IntegrationTest.php:
$this->assertSession()->pageTextContains(t('Search index'));
tests/src/Functional/IntegrationTest.php:
$this->submitForm([], t('Delete'));
tests/src/Functional/IntegrationTest.php:
$this->submitForm([], t('Delete'));
tests/src/Functional/IntegrationTest.php:
$this->assertSession()->responseContains(t('Are you sure you want to delete the search server %name?', ['%name' => $server->label()]));
tests/src/Functional/IntegrationTest.php:
$this->assertSession()->pageTextContains(t('Deleting a server will disable all its indexes and their searches.'));
tests/src/Functional/IntegrationTest.php:
$this->submitForm([], t('Delete'));
tests/src/Functional/IntegrationTest.php:
$this->assertSession()->responseContains(t('The search server %name has been deleted.', ['%name' => $server->label()]));
There are several usages of t() function in tests folder yet.
Comment #6
borisson_#5 is correct, we need to remove it from the actual tests. Keeping this issue at NW but restoring novice tag.
Comment #7
c.nish2k3 CreditAttribution: c.nish2k3 as a volunteer commentedComment #8
c.nish2k3 CreditAttribution: c.nish2k3 as a volunteer commentedComment #10
drunken monkeyThat's a good start, thanks!
However, when removing a
t()
call with arguments, you have to replace it withnew FormattableMarkup()
so the placeholders get replaced properly. (See test fails.)Comment #11
c.nish2k3 CreditAttribution: c.nish2k3 as a volunteer commentedThanks for the hint.
Comment #12
drunken monkeyGreat, thanks!
There are still some left, though, in the following files:
(See my
git grep
line in the issue summary.)Comment #13
kala4ekAttached updated patch.
Comment #14
hgunicamp CreditAttribution: hgunicamp at CI&T commentedI tested the 'remove_translations_from_all_tests-2870988-13.patch' patch and it looks nice for me.
Comment #15
hgunicamp CreditAttribution: hgunicamp at CI&T commentedComment #17
drunken monkeyLooks great now, thanks!
Committed.
Comment #18
drunken monkey