Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey created an issue. See original summary.

drunken monkey’s picture

sahilsharma011’s picture

Assigned: Unassigned » sahilsharma011

I'll work on a patch.

sahilsharma011’s picture

Assigned: sahilsharma011 » Unassigned
Status: Active » Needs review
FileSize
717 bytes

Patch provided. Please review.

rodrigoac’s picture

Status: Needs review » Needs work
Issue tags: -Novice +undefined

Hi 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.

borisson_’s picture

Issue tags: -undefined +Novice

#5 is correct, we need to remove it from the actual tests. Keeping this issue at NW but restoring novice tag.

c.nish2k3’s picture

Assigned: Unassigned » c.nish2k3
c.nish2k3’s picture

Assigned: c.nish2k3 » Unassigned
Status: Needs work » Needs review
FileSize
3.87 KB

Status: Needs review » Needs work

The last submitted patch, 8: remove_translations_from_all_tests-2870988-8.patch, failed testing.

drunken monkey’s picture

That's a good start, thanks!
However, when removing a t() call with arguments, you have to replace it with new FormattableMarkup() so the placeholders get replaced properly. (See test fails.)

c.nish2k3’s picture

Status: Needs work » Needs review
FileSize
3.91 KB

Thanks for the hint.

drunken monkey’s picture

Status: Needs review » Needs work

Great, thanks!

There are still some left, though, in the following files:

modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTes
modules/search_api_db/tests/src/FunctionalJavascript/IntegrationTest.php
modules/search_api_db/tests/src/Kernel/BackendTest.php

(See my git grep line in the issue summary.)

kala4ek’s picture

Status: Needs work » Needs review
FileSize
10.22 KB

Attached updated patch.

hgunicamp’s picture

Status: Needs review » Reviewed & tested by the community

I tested the 'remove_translations_from_all_tests-2870988-13.patch' patch and it looks nice for me.

hgunicamp’s picture

Issue tags: +ciandt-contrib

drunken monkey’s picture

Looks great now, thanks!
Committed.

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.