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`
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`
Comments
Comment #2
drunken monkeyComment #3
sahilsharma011 commentedI'll work on a patch.
Comment #4
sahilsharma011 commentedPatch provided. Please review.
Comment #5
rodrigoac 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 commentedComment #8
c.nish2k3 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 commentedThanks for the hint.
Comment #12
drunken monkeyGreat, thanks!
There are still some left, though, in the following files:
(See my
git grepline in the issue summary.)Comment #13
kala4ekAttached updated patch.
Comment #14
hgunicamp commentedI tested the 'remove_translations_from_all_tests-2870988-13.patch' patch and it looks nice for me.
Comment #15
hgunicamp commentedComment #17
drunken monkeyLooks great now, thanks!
Committed.
Comment #18
drunken monkey