Commit 497ebcd2 authored by xjm's avatar xjm
Browse files

Issue #2506445 by joelpittet, Ryan Weal, Sutharsan, alexpott, subhojit777,...

Issue #2506445 by joelpittet, Ryan Weal, Sutharsan, alexpott, subhojit777, justAChris, nlisgo, effulgentsia, rpayanm, larowlan, chx, xjm, dawehner, geertvd, lauriii, izus, andypost, borisson_, Sharique: Replace !placeholder with @placeholder in t() and format_string() for non-URLs in tests
parent 98be22d2
......@@ -40,7 +40,7 @@ public function testUpdateFeedItem() {
$this->assertResponse(200);
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
$this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed !name has been added.', array('!name' => $edit['title[0][value]'])));
$this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
$fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url[0][value]']))->fetchField();
$feed = Feed::load($fid);
......@@ -62,7 +62,7 @@ public function testUpdateFeedItem() {
$feed->refreshItems();
$after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
$this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (!before === !after)', array('!before' => $before, '!after' => $after)));
$this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (@before === @after)', array('@before' => $before, '@after' => $after)));
// Make sure updating items works even after uninstalling a module
// that provides the selected plugins.
......
......@@ -48,8 +48,8 @@ public function testBlockContentCreation() {
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
// Check that the Basic block has been created.
$this->assertRaw(format_string('!block %name has been created.', array(
'!block' => 'basic',
$this->assertRaw(format_string('@block %name has been created.', array(
'@block' => 'basic',
'%name' => $edit['info[0][value]']
)), 'Basic block created.');
......@@ -95,8 +95,8 @@ public function testBlockContentCreationMultipleViewModes() {
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
// Check that the Basic block has been created.
$this->assertRaw(format_string('!block %name has been created.', array(
'!block' => 'basic',
$this->assertRaw(format_string('@block %name has been created.', array(
'@block' => 'basic',
'%name' => $edit['info[0][value]']
)), 'Basic block created.');
......@@ -144,8 +144,8 @@ public function testDefaultBlockContentCreation() {
$this->drupalPostForm('block/add', $edit, t('Save'));
// Check that the block has been created and that it is a basic block.
$this->assertRaw(format_string('!block %name has been created.', array(
'!block' => 'basic',
$this->assertRaw(format_string('@block %name has been created.', array(
'@block' => 'basic',
'%name' => $edit['info[0][value]'],
)), 'Basic block created.');
......
......@@ -69,8 +69,8 @@ public function testRevisions() {
// Confirm the correct revision text appears.
$loaded = entity_revision_load('block_content', $revision_id);
// Verify revision log is the same.
$this->assertEqual($loaded->getRevisionLog(), $logs[$delta], format_string('Correct log message found for revision !revision', array(
'!revision' => $loaded->getRevisionId(),
$this->assertEqual($loaded->getRevisionLog(), $logs[$delta], format_string('Correct log message found for revision @revision', array(
'@revision' => $loaded->getRevisionId(),
)));
}
......
......@@ -64,7 +64,7 @@ public function testPageEdit() {
// Test deleting the block.
$this->drupalGet("block/" . $revised_block->id());
$this->clickLink(t('Delete'));
$this->assertText(format_string('Are you sure you want to delete the custom block !label?', array('!label' => $revised_block->label())));
$this->assertText(format_string('Are you sure you want to delete the custom block @label?', array('@label' => $revised_block->label())));
}
}
......@@ -273,8 +273,8 @@ public function testExportImportCollections() {
// Verify that there are configuration differences to import.
$this->drupalGet('admin/config/development/configuration');
$this->assertNoText(t('There are no configuration changes to import.'));
$this->assertText(t('!collection configuration collection', array('!collection' => 'collection.test1')));
$this->assertText(t('!collection configuration collection', array('!collection' => 'collection.test2')));
$this->assertText(t('@collection configuration collection', array('@collection' => 'collection.test1')));
$this->assertText(t('@collection configuration collection', array('@collection' => 'collection.test2')));
$this->assertText('config_test.create');
$this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.create');
$this->assertText('config_test.update');
......
......@@ -116,7 +116,7 @@ public function testMapperListPage() {
$entity_type = \Drupal::entityManager()->getDefinition($test_entity->getEntityTypeId());
$this->drupalGet($base_url . '/translate');
$title = t('!label !entity_type', array('!label' => $test_entity->label(), '!entity_type' => $entity_type->getLowercaseLabel()));
$title = t('@label @entity_type', array('@label' => $test_entity->label(), '@entity_type' => $entity_type->getLowercaseLabel()));
$title = t('Translations for %label', array('%label' => $title));
$this->assertRaw($title);
$this->assertRaw('<th>' . t('Language') . '</th>');
......
......@@ -370,7 +370,7 @@ public function testContactConfigEntityTranslation() {
// Test that delete links work and operations perform properly.
foreach ($this->langcodes as $langcode) {
$replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName());
$replacements = array('%label' => t('@label @entity_type', array('@label' => $label, '@entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName());
$this->drupalGet("$translation_base_url/$langcode/delete");
$this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements));
......
......@@ -129,7 +129,7 @@ function testSiteWideContact() {
$max_length = EntityTypeInterface::BUNDLE_MAX_LENGTH;
$max_length_exceeded = $max_length + 1;
$this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', array($recipients[0])), '', TRUE);
$this->assertText(format_string('Machine-readable name cannot be longer than !max characters but is currently !exceeded characters long.', array('!max' => $max_length, '!exceeded' => $max_length_exceeded)));
$this->assertText(format_string('Machine-readable name cannot be longer than @max characters but is currently @exceeded characters long.', array('@max' => $max_length, '@exceeded' => $max_length_exceeded)));
$this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', array($recipients[0])), '', TRUE);
$this->assertRaw(t('Contact form %label has been added.', array('%label' => $label)));
......
......@@ -208,7 +208,7 @@ function testFieldFormSingleRequired() {
// Submit with missing required value.
$edit = array();
$this->drupalPostForm('entity_test/add', $edit, t('Save'));
$this->assertRaw(t('!name field is required.', array('!name' => $this->field['label'])), 'Required field with no value fails validation');
$this->assertRaw(t('@name field is required.', array('@name' => $this->field['label'])), 'Required field with no value fails validation');
// Create an entity
$value = mt_rand(1, 127);
......@@ -228,7 +228,7 @@ function testFieldFormSingleRequired() {
"{$field_name}[0][value]" => $value,
);
$this->drupalPostForm('entity_test/manage/' . $id, $edit, t('Save'));
$this->assertRaw(t('!name field is required.', array('!name' => $this->field['label'])), 'Required field with no value fails validation');
$this->assertRaw(t('@name field is required.', array('@name' => $this->field['label'])), 'Required field with no value fails validation');
}
// function testFieldFormMultiple() {
......
......@@ -81,7 +81,7 @@ function _testTextfieldWidgets($field_type, $widget_type) {
$this->drupalGet('entity_test/add');
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
$this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed');
$this->assertRaw(format_string('placeholder="A placeholder on !widget_type"', array('!widget_type' => $widget_type)));
$this->assertRaw(format_string('placeholder="A placeholder on @widget_type"', array('@widget_type' => $widget_type)));
// Submit with some value.
$value = $this->randomMachineName();
......
......@@ -220,7 +220,7 @@ function testHandleDangerousFile() {
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
$this->assertRaw(t('File name is !filename', array('!filename' => $this->phpfile->filename)), 'Dangerous file was not renamed when insecure uploads is TRUE.');
$this->assertRaw(t('File name is @filename', array('@filename' => $this->phpfile->filename)), 'Dangerous file was not renamed when insecure uploads is TRUE.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
......@@ -254,7 +254,7 @@ function testHandleFileMunge() {
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.');
$this->assertRaw(t('File name is !filename', array('!filename' => $munged_filename)), 'File was successfully munged.');
$this->assertRaw(t('File name is @filename', array('@filename' => $munged_filename)), 'File was successfully munged.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
......@@ -272,7 +272,7 @@ function testHandleFileMunge() {
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
$this->assertRaw(t('File name is !filename', array('!filename' => $this->image->getFilename())), 'File was not munged when allowing any extension.');
$this->assertRaw(t('File name is @filename', array('@filename' => $this->image->getFilename())), 'File was not munged when allowing any extension.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
......
......@@ -280,7 +280,7 @@ function testFormatWidgetPermissions() {
$edit = array();
$edit['title[0][value]'] = $new_title;
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->assertText(t('!name field is required.', array('!name' => t('Text format'))), 'Error message is displayed.');
$this->assertText(t('@name field is required.', array('@name' => t('Text format'))), 'Error message is displayed.');
$this->drupalGet('node/' . $node->id());
$this->assertText($old_title, 'Old title found.');
$this->assertNoText($new_title, 'New title not found.');
......@@ -315,7 +315,7 @@ function testFormatWidgetPermissions() {
$edit = array();
$edit['title[0][value]'] = $new_title;
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->assertText(t('!name field is required.', array('!name' => t('Text format'))), 'Error message is displayed.');
$this->assertText(t('@name field is required.', array('@name' => t('Text format'))), 'Error message is displayed.');
$this->drupalGet('node/' . $node->id());
$this->assertText($old_title, 'Old title found.');
$this->assertNoText($new_title, 'New title not found.');
......
......@@ -40,8 +40,8 @@ public function testLanguageConfiguration() {
);
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Test validation on missing values.
$this->assertText(t('!name field is required.', array('!name' => t('Language code'))));
$this->assertText(t('!name field is required.', array('!name' => t('Language name'))));
$this->assertText(t('@name field is required.', array('@name' => t('Language code'))));
$this->assertText(t('@name field is required.', array('@name' => t('Language name'))));
$empty_language = new Language();
$this->assertFieldChecked('edit-direction-' . $empty_language->getDirection(), 'Consistent usage of language direction.');
$this->assertUrl(\Drupal::url('language.add', array(), array('absolute' => TRUE)), [], 'Correct page redirection.');
......
......@@ -277,14 +277,14 @@ function testLinkTitle() {
"{$field_name}[0][uri]" => 'http://www.example.com',
);
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText(t('!name field is required.', array('!name' => t('Link text'))));
$this->assertText(t('@name field is required.', array('@name' => t('Link text'))));
// Verify that the link text is not required, if the URL is empty.
$edit = array(
"{$field_name}[0][uri]" => '',
);
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertNoText(t('!name field is required.', array('!name' => t('Link text'))));
$this->assertNoText(t('@name field is required.', array('@name' => t('Link text'))));
// Verify that a URL and link text meets requirements.
$this->drupalGet('entity_test/add');
......@@ -293,7 +293,7 @@ function testLinkTitle() {
"{$field_name}[0][title]" => 'Example',
);
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertNoText(t('!name field is required.', array('!name' => t('Link text'))));
$this->assertNoText(t('@name field is required.', array('@name' => t('Link text'))));
}
}
}
......
......@@ -111,7 +111,7 @@ public function testInterface() {
// Check if translations are available for Drupal core.
$this->drupalGet('admin/reports/translations');
$this->assertText(t('Updates for: !project', array('!project' => t('Drupal core'))), 'Translations found');
$this->assertText(t('Updates for: @project', array('@project' => t('Drupal core'))), 'Translations found');
$this->assertText(SafeMarkup::format('@module (@date)', array('@module' => t('Drupal core'), '@date' => format_date(REQUEST_TIME, 'html_date'))), 'Core translation update');
$update_button = $this->xpath('//input[@type="submit"][@value="' . t('Update translations') . '"]');
$this->assertTrue($update_button, 'Update translations button');
......
......@@ -195,8 +195,8 @@ function addCustomMenu() {
// Verify that using a menu_name that is too long results in a validation
// message.
$this->assertRaw(t('!name cannot be longer than %max characters but is currently %length characters long.', array(
'!name' => t('Menu name'),
$this->assertRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', array(
'@name' => t('Menu name'),
'%max' => MENU_MAX_MENU_NAME_LENGTH_UI,
'%length' => Unicode::strlen($menu_name),
)));
......@@ -207,8 +207,8 @@ function addCustomMenu() {
$this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
// Verify that no validation error is given for menu_name length.
$this->assertNoRaw(t('!name cannot be longer than %max characters but is currently %length characters long.', array(
'!name' => t('Menu name'),
$this->assertNoRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', array(
'@name' => t('Menu name'),
'%max' => MENU_MAX_MENU_NAME_LENGTH_UI,
'%length' => Unicode::strlen($menu_name),
)));
......
......@@ -52,7 +52,7 @@ function testNodeCreation() {
$this->drupalPostForm('node/add/page', $edit, t('Save'));
// Check that the Basic page has been created.
$this->assertRaw(t('!post %title has been created.', array('!post' => 'Basic page', '%title' => $edit['title[0][value]'])), 'Basic page created.');
$this->assertRaw(t('@post %title has been created.', array('@post' => 'Basic page', '%title' => $edit['title[0][value]'])), 'Basic page created.');
// Check that the node exists in the database.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
......@@ -141,7 +141,7 @@ function testUnpublishedNodeCreation() {
$this->assertText(t('Test page text'));
// Confirm that the node was created.
$this->assertRaw(t('!post %title has been created.', array('!post' => 'Basic page', '%title' => $edit['title[0][value]'])));
$this->assertRaw(t('@post %title has been created.', array('@post' => 'Basic page', '%title' => $edit['title[0][value]'])));
}
/**
......
......@@ -45,16 +45,16 @@ function testNodeRSSContent() {
$this->drupalGet('rss.xml');
// Check that content added in 'rss' view mode appear in RSS feed.
$rss_only_content = t('Extra data that should appear only in the RSS feed for node !nid.', array('!nid' => $node->id()));
$rss_only_content = t('Extra data that should appear only in the RSS feed for node @nid.', array('@nid' => $node->id()));
$this->assertText($rss_only_content, 'Node content designated for RSS appear in RSS feed.');
// Check that content added in view modes other than 'rss' doesn't
// appear in RSS feed.
$non_rss_content = t('Extra data that should appear everywhere except the RSS feed for node !nid.', array('!nid' => $node->id()));
$non_rss_content = t('Extra data that should appear everywhere except the RSS feed for node @nid.', array('@nid' => $node->id()));
$this->assertNoText($non_rss_content, 'Node content not designed for RSS does not appear in RSS feed.');
// Check that extra RSS elements and namespaces are added to RSS feed.
$test_element = '<testElement>' . t('Value of testElement RSS element for node !nid.', array('!nid' => $node->id())) . '</testElement>';
$test_element = '<testElement>' . t('Value of testElement RSS element for node @nid.', array('@nid' => $node->id())) . '</testElement>';
$test_ns = 'xmlns:drupaltest="http://example.com/test-namespace"';
$this->assertRaw($test_element, 'Extra RSS elements appear in RSS feed.');
$this->assertRaw($test_ns, 'Extra namespaces appear in RSS feed.');
......
......@@ -20,12 +20,12 @@ function node_test_node_view(array &$build, NodeInterface $node, EntityViewDispl
// Add RSS elements and namespaces when building the RSS feed.
$node->rss_elements[] = array(
'key' => 'testElement',
'value' => t('Value of testElement RSS element for node !nid.', array('!nid' => $node->id())),
'value' => t('Value of testElement RSS element for node @nid.', array('@nid' => $node->id())),
);
// Add content that should be displayed only in the RSS feed.
$build['extra_feed_content'] = array(
'#markup' => '<p>' . t('Extra data that should appear only in the RSS feed for node !nid.', array('!nid' => $node->id())) . '</p>',
'#markup' => '<p>' . t('Extra data that should appear only in the RSS feed for node @nid.', array('@nid' => $node->id())) . '</p>',
'#weight' => 10,
);
}
......@@ -33,7 +33,7 @@ function node_test_node_view(array &$build, NodeInterface $node, EntityViewDispl
if ($view_mode != 'rss') {
// Add content that should NOT be displayed in the RSS feed.
$build['extra_non_feed_content'] = array(
'#markup' => '<p>' . t('Extra data that should appear everywhere except the RSS feed for node !nid.', array('!nid' => $node->id())) . '</p>',
'#markup' => '<p>' . t('Extra data that should appear everywhere except the RSS feed for node @nid.', array('@nid' => $node->id())) . '</p>',
);
}
}
......
......@@ -326,7 +326,7 @@ function testNodeDisplay() {
);
$this->drupalPostForm($this->adminPath, $edit, t('Save field settings'));
$this->assertText(format_string('Updated field !field_name field settings.', array('!field_name' => $this->fieldName)), "The 'On' and 'Off' form fields work for boolean fields.");
$this->assertText(format_string('Updated field @field_name field settings.', array('@field_name' => $this->fieldName)), "The 'On' and 'Off' form fields work for boolean fields.");
// Select a default value.
$edit = array(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment