Issue #3153150 by Suresh Prabhu Parkala, paulocs, ravi.shankar, Deepak Goyal, Hardik_Patel_12, longwave: Remove uses of t() in assertTrue() and assertFalse() calls

merge-requests/7/head
catch 2020-08-28 10:07:33 +01:00
parent b7f992cfff
commit 3ab889a1aa
7 changed files with 28 additions and 27 deletions

View File

@ -101,7 +101,8 @@ class CommentInterfaceTest extends CommentTestBase {
// Test changing the comment author to "Anonymous". // Test changing the comment author to "Anonymous".
$comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['uid' => '']); $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['uid' => '']);
$this->assertTrue($comment->getAuthorName() == t('Anonymous') && $comment->getOwnerId() == 0, 'Comment author successfully changed to anonymous.'); $this->assertTrue($comment->getAuthorName() == 'Anonymous', 'Comment author successfully changed to anonymous.');
$this->assertTrue($comment->getOwnerId() == 0, 'Comment author successfully changed to anonymous.');
// Test changing the comment author to an unverified user. // Test changing the comment author to an unverified user.
$random_name = $this->randomMachineName(); $random_name = $this->randomMachineName();

View File

@ -272,7 +272,7 @@ class FormTest extends FieldTestBase {
// Check if aria-describedby attribute is placed on multiple value widgets. // Check if aria-describedby attribute is placed on multiple value widgets.
$elements = $this->xpath('//table[@id="field-unlimited-values" and @aria-describedby="edit-field-unlimited--description"]'); $elements = $this->xpath('//table[@id="field-unlimited-values" and @aria-describedby="edit-field-unlimited--description"]');
$this->assertTrue(isset($elements[0]), t('aria-describedby attribute is properly placed on multiple value widgets.')); $this->assertTrue(isset($elements[0]), 'aria-describedby attribute is properly placed on multiple value widgets.');
// Press 'add more' button -> 2 widgets. // Press 'add more' button -> 2 widgets.
$this->drupalPostForm(NULL, [], t('Add another item')); $this->drupalPostForm(NULL, [], t('Add another item'));

View File

@ -276,12 +276,12 @@ class LanguageSwitchingTest extends BrowserTestBase {
// Check if the default (English) admin/config page has the right class. // Check if the default (English) admin/config page has the right class.
$this->drupalGet('admin/config'); $this->drupalGet('admin/config');
$class = $this->xpath('//body[contains(@class, :class)]', [':class' => $searched_class]); $class = $this->xpath('//body[contains(@class, :class)]', [':class' => $searched_class]);
$this->assertTrue(isset($class[0]), t('The path-admin class appears on default language.')); $this->assertTrue(isset($class[0]), 'The path-admin class appears on default language.');
// Check if the French admin/config page has the right class. // Check if the French admin/config page has the right class.
$this->drupalGet('fr/admin/config'); $this->drupalGet('fr/admin/config');
$class = $this->xpath('//body[contains(@class, :class)]', [':class' => $searched_class]); $class = $this->xpath('//body[contains(@class, :class)]', [':class' => $searched_class]);
$this->assertTrue(isset($class[0]), t('The path-admin class same as on default language.')); $this->assertTrue(isset($class[0]), 'The path-admin class same as on default language.');
// The testing profile sets the user/login page as the frontpage. That // The testing profile sets the user/login page as the frontpage. That
// redirects authenticated users to their profile page, so check with an // redirects authenticated users to their profile page, so check with an
@ -316,17 +316,17 @@ class LanguageSwitchingTest extends BrowserTestBase {
// Language code 'none' link should be active. // Language code 'none' link should be active.
$langcode = 'none'; $langcode = 'none';
$links = $this->xpath('//a[@id = :id and @data-drupal-link-system-path = :path]', [':id' => 'no_lang_link', ':path' => $path]); $links = $this->xpath('//a[@id = :id and @data-drupal-link-system-path = :path]', [':id' => 'no_lang_link', ':path' => $path]);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.');
// Language code 'en' link should be active. // Language code 'en' link should be active.
$langcode = 'en'; $langcode = 'en';
$links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'en_link', ':lang' => 'en', ':path' => $path]); $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'en_link', ':lang' => 'en', ':path' => $path]);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.');
// Language code 'fr' link should not be active. // Language code 'fr' link should not be active.
$langcode = 'fr'; $langcode = 'fr';
$links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'fr_link', ':lang' => 'fr', ':path' => $path]); $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'fr_link', ':lang' => 'fr', ':path' => $path]);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to NOT mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode has the correct attributes that will allow the drupal.active-link library to NOT mark it as active.');
// Verify that drupalSettings contains the correct values. // Verify that drupalSettings contains the correct values.
$settings = $this->getDrupalSettings(); $settings = $this->getDrupalSettings();
@ -341,17 +341,17 @@ class LanguageSwitchingTest extends BrowserTestBase {
// Language code 'none' link should be active. // Language code 'none' link should be active.
$langcode = 'none'; $langcode = 'none';
$links = $this->xpath('//a[@id = :id and @data-drupal-link-system-path = :path]', [':id' => 'no_lang_link', ':path' => $path]); $links = $this->xpath('//a[@id = :id and @data-drupal-link-system-path = :path]', [':id' => 'no_lang_link', ':path' => $path]);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.');
// Language code 'en' link should not be active. // Language code 'en' link should not be active.
$langcode = 'en'; $langcode = 'en';
$links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'en_link', ':lang' => 'en', ':path' => $path]); $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'en_link', ':lang' => 'en', ':path' => $path]);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to NOT mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode has the correct attributes that will allow the drupal.active-link library to NOT mark it as active.');
// Language code 'fr' link should be active. // Language code 'fr' link should be active.
$langcode = 'fr'; $langcode = 'fr';
$links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'fr_link', ':lang' => 'fr', ':path' => $path]); $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'fr_link', ':lang' => 'fr', ':path' => $path]);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.');
// Verify that drupalSettings contains the correct values. // Verify that drupalSettings contains the correct values.
$settings = $this->getDrupalSettings(); $settings = $this->getDrupalSettings();
@ -377,17 +377,17 @@ class LanguageSwitchingTest extends BrowserTestBase {
// Language code 'none' link should be active. // Language code 'none' link should be active.
$langcode = 'none'; $langcode = 'none';
$links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'no_lang_link', ':class' => 'is-active']); $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'no_lang_link', ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode is marked active.');
// Language code 'en' link should be active. // Language code 'en' link should be active.
$langcode = 'en'; $langcode = 'en';
$links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'en_link', ':class' => 'is-active']); $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'en_link', ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode is marked active.');
// Language code 'fr' link should not be active. // Language code 'fr' link should not be active.
$langcode = 'fr'; $langcode = 'fr';
$links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', [':id' => 'fr_link', ':class' => 'is-active']); $links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', [':id' => 'fr_link', ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode is NOT marked active.');
// Test links generated by the link generator on a French page. // Test links generated by the link generator on a French page.
$current_language = 'French'; $current_language = 'French';
@ -396,17 +396,17 @@ class LanguageSwitchingTest extends BrowserTestBase {
// Language code 'none' link should be active. // Language code 'none' link should be active.
$langcode = 'none'; $langcode = 'none';
$links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'no_lang_link', ':class' => 'is-active']); $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'no_lang_link', ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode is marked active.');
// Language code 'en' link should not be active. // Language code 'en' link should not be active.
$langcode = 'en'; $langcode = 'en';
$links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', [':id' => 'en_link', ':class' => 'is-active']); $links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', [':id' => 'en_link', ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode is NOT marked active.');
// Language code 'fr' link should be active. // Language code 'fr' link should be active.
$langcode = 'fr'; $langcode = 'fr';
$links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'fr_link', ':class' => 'is-active']); $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'fr_link', ':class' => 'is-active']);
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); $this->assertTrue(isset($links[0]), 'A link generated by $function_name to the current $current_language page with langcode $langcode is marked active.');
} }
/** /**

View File

@ -118,7 +118,7 @@ class SearchNodeUpdateAndDeletionTest extends BrowserTestBase {
->condition('word', 'dragons') ->condition('word', 'dragons')
->execute() ->execute()
->fetchField(); ->fetchField();
$this->assertFalse($search_index_dataset, t('Node info successfully removed from search_index')); $this->assertFalse($search_index_dataset, 'Node info successfully removed from search_index');
// Search again to verify the node doesn't appear anymore. // Search again to verify the node doesn't appear anymore.
$this->drupalPostForm('search/node', $edit, t('Search')); $this->drupalPostForm('search/node', $edit, t('Search'));

View File

@ -123,13 +123,13 @@ class ElementsLabelsTest extends BrowserTestBase {
$field_id = 'edit-form-textfield-test-description-after'; $field_id = 'edit-form-textfield-test-description-after';
$description_id = $field_id . '--description'; $description_id = $field_id . '--description';
$elements = $this->xpath('//input[@id="' . $field_id . '" and @aria-describedby="' . $description_id . '"]/following-sibling::div[@id="' . $description_id . '"]'); $elements = $this->xpath('//input[@id="' . $field_id . '" and @aria-describedby="' . $description_id . '"]/following-sibling::div[@id="' . $description_id . '"]');
$this->assertTrue(isset($elements[0]), t('Properly places the #description element after the form item.')); $this->assertTrue(isset($elements[0]), 'Properly places the #description element after the form item.');
// Check #description placement with #description_display='before'. // Check #description placement with #description_display='before'.
$field_id = 'edit-form-textfield-test-description-before'; $field_id = 'edit-form-textfield-test-description-before';
$description_id = $field_id . '--description'; $description_id = $field_id . '--description';
$elements = $this->xpath('//input[@id="' . $field_id . '" and @aria-describedby="' . $description_id . '"]/preceding-sibling::div[@id="' . $description_id . '"]'); $elements = $this->xpath('//input[@id="' . $field_id . '" and @aria-describedby="' . $description_id . '"]/preceding-sibling::div[@id="' . $description_id . '"]');
$this->assertTrue(isset($elements[0]), t('Properly places the #description element before the form item.')); $this->assertTrue(isset($elements[0]), 'Properly places the #description element before the form item.');
// Check if the class is 'visually-hidden' on the form element description // Check if the class is 'visually-hidden' on the form element description
// for the option with #description_display='invisible' and also check that // for the option with #description_display='invisible' and also check that
@ -137,7 +137,7 @@ class ElementsLabelsTest extends BrowserTestBase {
$field_id = 'edit-form-textfield-test-description-invisible'; $field_id = 'edit-form-textfield-test-description-invisible';
$description_id = $field_id . '--description'; $description_id = $field_id . '--description';
$elements = $this->xpath('//input[@id="' . $field_id . '" and @aria-describedby="' . $description_id . '"]/following-sibling::div[contains(@class, "visually-hidden")]'); $elements = $this->xpath('//input[@id="' . $field_id . '" and @aria-describedby="' . $description_id . '"]/following-sibling::div[contains(@class, "visually-hidden")]');
$this->assertTrue(isset($elements[0]), t('Properly renders the #description element visually-hidden.')); $this->assertTrue(isset($elements[0]), 'Properly renders the #description element visually-hidden.');
} }
/** /**

View File

@ -379,7 +379,7 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
]; ];
$schema = Database::getConnection()->schema(); $schema = Database::getConnection()->schema();
foreach ($tables as $table_name) { foreach ($tables as $table_name) {
$this->assertTrue($schema->tableExists($table_name), t('Table %table exists.', ['%table' => $table_name])); $this->assertTrue($schema->tableExists($table_name), 'Table $table_name exists.');
} }
} }
@ -405,8 +405,8 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
// Verify the indexes we will create do not exist yet. // Verify the indexes we will create do not exist yet.
foreach ($tables as $table) { foreach ($tables as $table) {
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), t("No index named value exists in @table", ['@table' => $table])); $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), 'No index named value exists in $table');
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), t("No index named value_format exists in @table", ['@table' => $table])); $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), 'No index named value_format exists in $table');
} }
// Add data so the table cannot be dropped. // Add data so the table cannot be dropped.
@ -424,15 +424,15 @@ class FieldSqlStorageTest extends EntityKernelTestBase {
$field_storage->setIndexes(['value' => [['value', 255]]]); $field_storage->setIndexes(['value' => [['value', 255]]]);
$field_storage->save(); $field_storage->save();
foreach ($tables as $table) { foreach ($tables as $table) {
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in @table", ['@table' => $table])); $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), "Index on value created in @table", ['@table' => $table]);
} }
// Add a different index, removing the existing custom one. // Add a different index, removing the existing custom one.
$field_storage->setIndexes(['value_format' => [['value', 127], ['format', 127]]]); $field_storage->setIndexes(['value_format' => [['value', 127], ['format', 127]]]);
$field_storage->save(); $field_storage->save();
foreach ($tables as $table) { foreach ($tables as $table) {
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in @table", ['@table' => $table])); $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), "Index on value_format created in @table", ['@table' => $table]);
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in @table", ['@table' => $table])); $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), "Index on value removed in @table", ['@table' => $table]);
} }
// Verify that the tables were not dropped in the process. // Verify that the tables were not dropped in the process.

View File

@ -37,7 +37,7 @@ class DirectoryTest extends FileTestBase {
$child_path = $parent_path . DIRECTORY_SEPARATOR . $child; $child_path = $parent_path . DIRECTORY_SEPARATOR . $child;
/** @var \Drupal\Core\File\FileSystemInterface $file_system */ /** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system'); $file_system = \Drupal::service('file_system');
$this->assertTrue($file_system->mkdir($child_path, 0775, TRUE), t('No error reported when creating new local directories.'), 'File'); $this->assertTrue($file_system->mkdir($child_path, 0775, TRUE), 'No error reported when creating new local directories.');
// Ensure new directories also exist. // Ensure new directories also exist.
$this->assertDirectoryExists($parent_path); $this->assertDirectoryExists($parent_path);