diff --git a/core/modules/aggregator/src/FeedForm.php b/core/modules/aggregator/src/FeedForm.php index 39ccdfa2fddb09d13b022238be3c433e444ac370..3447cc8c0f4537aace66670ae49a282c61c85362 100644 --- a/core/modules/aggregator/src/FeedForm.php +++ b/core/modules/aggregator/src/FeedForm.php @@ -16,13 +16,16 @@ class FeedForm extends ContentEntityForm { */ public function save(array $form, FormStateInterface $form_state) { $feed = $this->entity; - if ($feed->save() == SAVED_UPDATED) { - drupal_set_message($this->t('The feed %feed has been updated.', array('%feed' => $feed->label()))); + $status = $feed->save(); + $label = $feed->label(); + $view_link = $feed->link($label, 'canonical'); + if ($status == SAVED_UPDATED) { + drupal_set_message($this->t('The feed %feed has been updated.', array('%feed' => $view_link))); $form_state->setRedirectUrl($feed->urlInfo('canonical')); } else { $this->logger('aggregator')->notice('Feed %feed added.', array('%feed' => $feed->label(), 'link' => $this->l($this->t('View'), new Url('aggregator.admin_overview')))); - drupal_set_message($this->t('The feed %feed has been added.', array('%feed' => $feed->label()))); + drupal_set_message($this->t('The feed %feed has been added.', array('%feed' => $view_link))); } } diff --git a/core/modules/aggregator/src/Tests/AggregatorTestBase.php b/core/modules/aggregator/src/Tests/AggregatorTestBase.php index 1777fe507ee24519e1ee88019fc97910a60469a7..15be1448bc715f14152711b75bdc95598de4b9d0 100644 --- a/core/modules/aggregator/src/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/src/Tests/AggregatorTestBase.php @@ -61,7 +61,11 @@ protected function setUp() { public function createFeed($feed_url = NULL, array $edit = array()) { $edit = $this->getFeedEditArray($feed_url, $edit); $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->assertText(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]']))); + + // Verify that the creation message contains a link to a feed. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/')); + $this->assert(isset($view_link), 'The message area contains a link to a feed'); $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']))->fetchField(); $this->assertTrue(!empty($fid), 'The feed found in database.'); diff --git a/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php b/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php index c1c3df907c60a0f463cdca5a37aeb35a154c1bdf..ae78205bcd5963392276dfaeb315f4b378f7aca4 100644 --- a/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php +++ b/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php @@ -35,7 +35,11 @@ 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->assertText(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]']))); + + // Verify that the creation message contains a link to a feed. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/')); + $this->assert(isset($view_link), 'The message area contains a link to a feed'); $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url[0][value]']))->fetchField(); $feed = Feed::load($fid); diff --git a/core/modules/aggregator/src/Tests/UpdateFeedTest.php b/core/modules/aggregator/src/Tests/UpdateFeedTest.php index 6bfb0f15652d3a472b2ad6d1e1b673f47bab17d0..8c797a5e828532379571097afd90945a64bf7a26 100644 --- a/core/modules/aggregator/src/Tests/UpdateFeedTest.php +++ b/core/modules/aggregator/src/Tests/UpdateFeedTest.php @@ -24,7 +24,11 @@ public function testUpdateFeed() { $edit[$same_field] = $feed->{$same_field}->value; } $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, t('Save')); - $this->assertRaw(t('The feed %name has been updated.', array('%name' => $edit['title[0][value]'])), format_string('The feed %name has been updated.', array('%name' => $edit['title[0][value]']))); + $this->assertText(t('The feed @name has been updated.', array('@name' => $edit['title[0][value]'])), format_string('The feed %name has been updated.', array('%name' => $edit['title[0][value]']))); + + // Verify that the creation message contains a link to a feed. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/')); + $this->assert(isset($view_link), 'The message area contains a link to a feed'); // Check feed data. $this->assertUrl($feed->url('canonical', ['absolute' => TRUE])); diff --git a/core/modules/contact/src/ContactFormEditForm.php b/core/modules/contact/src/ContactFormEditForm.php index 3b7dbe3b1e3cd505cd4228a812d0dc0b9e7dd366..4eacea2ea2c0b9b8044f32cc0358b20782ded904 100644 --- a/core/modules/contact/src/ContactFormEditForm.php +++ b/core/modules/contact/src/ContactFormEditForm.php @@ -130,12 +130,13 @@ public function save(array $form, FormStateInterface $form_state) { $contact_settings = $this->config('contact.settings'); $edit_link = $this->entity->link($this->t('Edit')); + $view_link = $contact_form->link($contact_form->label(), 'canonical'); if ($status == SAVED_UPDATED) { - drupal_set_message($this->t('Contact form %label has been updated.', array('%label' => $contact_form->label()))); + drupal_set_message($this->t('Contact form %label has been updated.', array('%label' => $view_link))); $this->logger('contact')->notice('Contact form %label has been updated.', array('%label' => $contact_form->label(), 'link' => $edit_link)); } else { - drupal_set_message($this->t('Contact form %label has been added.', array('%label' => $contact_form->label()))); + drupal_set_message($this->t('Contact form %label has been added.', array('%label' => $view_link))); $this->logger('contact')->notice('Contact form %label has been added.', array('%label' => $contact_form->label(), 'link' => $edit_link)); } diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/src/Tests/ContactSitewideTest.php index ce6938886808af849a0ce2aa92400a9d893ab23f..b049f2517f53e39fdfaf2a311224cfb5eab9f04f 100644 --- a/core/modules/contact/src/Tests/ContactSitewideTest.php +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php @@ -127,11 +127,19 @@ function testSiteWideContact() { $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->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))); + $this->assertText(t('Contact form @label has been added.', array('@label' => $label))); + + // Verify that the creation message contains a link to a contact form. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'contact/')); + $this->assert(isset($view_link), 'The message area contains a link to a contact form.'); // Create first valid form. $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0])), '', TRUE); - $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); + $this->assertText(t('Contact form @label has been added.', array('@label' => $label))); + + // Verify that the creation message contains a link to a contact form. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'contact/')); + $this->assert(isset($view_link), 'The message area contains a link to a contact form.'); // Check that the form was created in site default language. $langcode = $this->config('contact.form.' . $id)->get('langcode'); @@ -152,7 +160,7 @@ function testSiteWideContact() { $this->assertEqual($config['recipients'], array($recipients[0], $recipients[1])); $this->assertEqual($config['reply'], $reply); $this->assertNotEqual($id, $this->config('contact.settings')->get('default_form')); - $this->assertRaw(t('Contact form %label has been updated.', array('%label' => $label))); + $this->assertText(t('Contact form @label has been updated.', array('@label' => $label))); // Ensure the label is displayed on the contact page for this form. $this->drupalGet('contact/' . $id); $this->assertText($label); @@ -170,14 +178,14 @@ function testSiteWideContact() { // Add more forms. $this->addContactForm(Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE); - $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); + $this->assertText(t('Contact form @label has been added.', array('@label' => $label))); $this->addContactForm($name = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0], $recipients[1], $recipients[2])), '', FALSE); - $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); + $this->assertText(t('Contact form @label has been added.', array('@label' => $label))); // Try adding a form that already exists. $this->addContactForm($name, $label, '', '', FALSE); - $this->assertNoRaw(t('Contact form %label has been added.', array('%label' => $label))); + $this->assertNoText(t('Contact form @label has been added.', array('@label' => $label))); $this->assertRaw(t('The machine-readable name is already in use. It must be unique.')); $this->drupalLogout(); diff --git a/core/modules/contact/src/Tests/ContactStorageTest.php b/core/modules/contact/src/Tests/ContactStorageTest.php index 0a5dbb56f70c866036f143a7900e8d5815c1ed57..6fd3edd2df1b93a94482850866599e3580c93a7b 100644 --- a/core/modules/contact/src/Tests/ContactStorageTest.php +++ b/core/modules/contact/src/Tests/ContactStorageTest.php @@ -50,7 +50,7 @@ public function testContactStorage() { $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($mail)), '', TRUE, [ 'send_a_pony' => 1, ]); - $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); + $this->assertText(t('Contact form @label has been added.', array('@label' => $label))); // Ensure that anonymous can submit site-wide contact form. user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form')); diff --git a/core/modules/filter/src/Tests/FilterAdminTest.php b/core/modules/filter/src/Tests/FilterAdminTest.php index abb7e80fad7a0e03211149bc7351109ffbdf844c..e71b57ab45c4280197401462071577fac4150e5f 100644 --- a/core/modules/filter/src/Tests/FilterAdminTest.php +++ b/core/modules/filter/src/Tests/FilterAdminTest.php @@ -294,7 +294,11 @@ function testFilterAdmin() { $edit['body[0][value]'] = $text; $edit['body[0][format]'] = $basic; $this->drupalPostForm('node/add/page', $edit, t('Save')); - $this->assertRaw(t('Basic page %title has been created.', array('%title' => $edit['title[0][value]'])), 'Filtered node created.'); + $this->assertText(t('Basic page @title has been created.', array('@title' => $edit['title[0][value]'])), 'Filtered node created.'); + + // Verify that the creation message contains a link to a node. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/')); + $this->assert(isset($view_link), 'The message area contains a link to a node'); $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->assertTrue($node, 'Node found in database.'); diff --git a/core/modules/forum/src/Form/ForumForm.php b/core/modules/forum/src/Form/ForumForm.php index 415fef79a8b51f9b711d65eea07eadeae2c37d4f..30f0cf1466e6d459cc7c4e40fe38ea2ef6fd534a 100644 --- a/core/modules/forum/src/Form/ForumForm.php +++ b/core/modules/forum/src/Form/ForumForm.php @@ -78,9 +78,10 @@ public function save(array $form, FormStateInterface $form_state) { $route_name = $this->urlStub == 'container' ? 'entity.taxonomy_term.forum_edit_container_form' : 'entity.taxonomy_term.forum_edit_form'; $route_parameters = ['taxonomy_term' => $term->id()]; $link = $this->l($this->t('Edit'), new Url($route_name, $route_parameters)); + $view_link = $term->link($term->getName()); switch ($status) { case SAVED_NEW: - drupal_set_message($this->t('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType))); + drupal_set_message($this->t('Created new @type %term.', array('%term' => $view_link, '@type' => $this->forumFormType))); $this->logger('forum')->notice('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link)); $form_state->setValue('tid', $term->id()); break; diff --git a/core/modules/forum/src/Tests/ForumTest.php b/core/modules/forum/src/Tests/ForumTest.php index 1327714c4aaf877115b8bc2b7d6c0cc3d10922ca..df21f69e50788b9c79dc3cfd5a1a4fbb4a71c8c1 100644 --- a/core/modules/forum/src/Tests/ForumTest.php +++ b/core/modules/forum/src/Tests/ForumTest.php @@ -415,14 +415,18 @@ function createForum($type, $parent = 0) { $this->drupalPostForm('admin/structure/forum/add/' . $type, $edit, t('Save')); $this->assertResponse(200); $type = ($type == 'container') ? 'forum container' : 'forum'; - $this->assertRaw( + $this->assertText( t( - 'Created new @type %term.', - array('%term' => $name, '@type' => t($type)) + 'Created new @type @term.', + array('@term' => $name, '@type' => t($type)) ), format_string('@type was created', array('@type' => ucfirst($type))) ); + // Verify that the creation message contains a link to a term. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'term/')); + $this->assert(isset($view_link), 'The message area contains a link to a term'); + // Verify forum. $term = db_query("SELECT * FROM {taxonomy_term_field_data} t WHERE t.vid = :vid AND t.name = :name AND t.description__value = :desc AND t.default_langcode = 1", array(':vid' => $this->config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description))->fetchAssoc(); $this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database'); @@ -540,13 +544,17 @@ function createForumTopic($forum, $container = FALSE) { $type = t('Forum topic'); if ($container) { - $this->assertNoRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), 'Forum topic was not created'); + $this->assertNoText(t('@type @title has been created.', array('@type' => $type, '@title' => $title)), 'Forum topic was not created'); $this->assertRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'Error message was shown'); return; } else { - $this->assertRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), 'Forum topic was created'); + $this->assertText(t('@type @title has been created.', array('@type' => $type, '@title' => $title)), 'Forum topic was created'); $this->assertNoRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'No error message was shown'); + + // Verify that the creation message contains a link to a term. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'term/')); + $this->assert(isset($view_link), 'The message area contains a link to a term'); } // Retrieve node object, ensure that the topic was created and in the proper forum. @@ -622,7 +630,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { $edit['taxonomy_forums'] = $this->rootForum['tid']; $edit['shadow'] = TRUE; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); - $this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit['title[0][value]'])), 'Forum node was edited'); + $this->assertText(t('Forum topic @title has been updated.', array('@title' => $edit['title[0][value]'])), 'Forum node was edited'); // Verify topic was moved to a different forum. $forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", array( diff --git a/core/modules/locale/src/Tests/LocaleContentTest.php b/core/modules/locale/src/Tests/LocaleContentTest.php index 07021fafff8994c24be9eca391d3688a497ff7cd..188b57433429e539ae6c687bdab62c294e7c97f5 100644 --- a/core/modules/locale/src/Tests/LocaleContentTest.php +++ b/core/modules/locale/src/Tests/LocaleContentTest.php @@ -118,7 +118,11 @@ public function testContentTypeLanguageConfiguration() { 'langcode[0][value]' => 'en', ); $this->drupalPostForm($path, $edit, t('Save')); - $this->assertRaw(t('%title has been updated.', array('%title' => $node_title))); + $this->assertText(t('@title has been updated.', array('@title' => $node_title))); + + // Verify that the creation message contains a link to a node. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/' . $node->id())); + $this->assert(isset($view_link), 'The message area contains the link to the edited node'); $this->drupalLogout(); } diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 4d1c42cd18538a33ad96d1cf8bdd9e00dbac5c81..82faab70843eae880e41aa57ec6b2ad941bdfcb9 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -356,7 +356,7 @@ public function save(array $form, FormStateInterface $form_state) { $node->save(); $node_link = $node->link($this->t('View')); $context = array('@type' => $node->getType(), '%title' => $node->label(), 'link' => $node_link); - $t_args = array('@type' => node_get_type_label($node), '%title' => $node->label()); + $t_args = array('@type' => node_get_type_label($node), '%title' => $node->link($node->label())); if ($insert) { $this->logger('content')->notice('@type: added %title.', $context); diff --git a/core/modules/node/src/Tests/NodeCreationTest.php b/core/modules/node/src/Tests/NodeCreationTest.php index 507105636ed655766def4ac3d06113e9e9662c1b..bf3ce864cbd6c4131e060bea984f93ca2c8324c6 100644 --- a/core/modules/node/src/Tests/NodeCreationTest.php +++ b/core/modules/node/src/Tests/NodeCreationTest.php @@ -48,7 +48,11 @@ 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->assertText(t('@post @title has been created.', array('@post' => 'Basic page', '@title' => $edit['title[0][value]'])), 'Basic page created.'); + + // Verify that the creation message contains a link to a node. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/')); + $this->assert(isset($view_link), 'The message area contains a link to a node'); // Check that the node exists in the database. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); @@ -137,7 +141,11 @@ 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->assertText(t('@post @title has been created.', array('@post' => 'Basic page', '@title' => $edit['title[0][value]']))); + + // Verify that the creation message contains a link to a node. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/')); + $this->assert(isset($view_link), 'The message area contains a link to a node'); } /** diff --git a/core/modules/shortcut/src/ShortcutForm.php b/core/modules/shortcut/src/ShortcutForm.php index 8161a02a06e91c1f2d203d7feb6c86d93d9e3700..b87db1bce89ae4418c026952d360730473d41621 100644 --- a/core/modules/shortcut/src/ShortcutForm.php +++ b/core/modules/shortcut/src/ShortcutForm.php @@ -23,12 +23,22 @@ class ShortcutForm extends ContentEntityForm { public function save(array $form, FormStateInterface $form_state) { $entity = $this->entity; $status = $entity->save(); + $url = $entity->getUrl(); + // There's an edge case where a user can have permission to + // 'link to any content', but has no right to access the linked page. So we + // check the access before showing the link. + if ($url->access()) { + $view_link = \Drupal::l($entity->getTitle(), $url); + } + else { + $view_link = $entity->getTitle(); + } if ($status == SAVED_UPDATED) { - $message = $this->t('The shortcut %link has been updated.', array('%link' => $entity->getTitle())); + $message = $this->t('The shortcut %link has been updated.', array('%link' => $view_link)); } else { - $message = $this->t('Added a shortcut for %title.', array('%title' => $entity->getTitle())); + $message = $this->t('Added a shortcut for %title.', array('%title' => $view_link)); } drupal_set_message($message); diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php index 101569ce178775c0bfc0a8a35f38f016ba363615..d64e0192f358d81c7aa2bf89e63c49ea88404e6c 100644 --- a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php @@ -86,7 +86,11 @@ function testEntityFormLanguage() { $edit['body[0][value]'] = $this->randomMachineName(16); $edit['langcode[0][value]'] = $langcode; $this->drupalPostForm('node/add/page', $edit, t('Save')); - $this->assertRaw(t('Basic page %title has been created.', array('%title' => $edit['title[0][value]'])), 'Basic page created.'); + $this->assertText(t('Basic page @title has been created.', array('@title' => $edit['title[0][value]'])), 'Basic page created.'); + + // Verify that the creation message contains a link to a node. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/')); + $this->assert(isset($view_link), 'The message area contains a link to a node'); // Check to make sure the node was created. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); diff --git a/core/modules/taxonomy/src/TermForm.php b/core/modules/taxonomy/src/TermForm.php index 17ac5c2be1902ddb6f63cc6bedf976a2f62406bb..cf05932e52bbff5aa188b2c8567542bbf72bf5bf 100644 --- a/core/modules/taxonomy/src/TermForm.php +++ b/core/modules/taxonomy/src/TermForm.php @@ -123,15 +123,16 @@ public function save(array $form, FormStateInterface $form_state) { $result = $term->save(); - $link = $term->link($this->t('Edit'), 'edit-form'); + $edit_link = $term->link($this->t('Edit'), 'edit-form'); + $view_link = $term->link($term->getName()); switch ($result) { case SAVED_NEW: - drupal_set_message($this->t('Created new term %term.', array('%term' => $term->getName()))); - $this->logger('taxonomy')->notice('Created new term %term.', array('%term' => $term->getName(), 'link' => $link)); + drupal_set_message($this->t('Created new term %term.', array('%term' => $view_link))); + $this->logger('taxonomy')->notice('Created new term %term.', array('%term' => $term->getName(), 'link' => $edit_link)); break; case SAVED_UPDATED: - drupal_set_message($this->t('Updated term %term.', array('%term' => $term->getName()))); - $this->logger('taxonomy')->notice('Updated term %term.', array('%term' => $term->getName(), 'link' => $link)); + drupal_set_message($this->t('Updated term %term.', array('%term' => $view_link))); + $this->logger('taxonomy')->notice('Updated term %term.', array('%term' => $term->getName(), 'link' => $edit_link)); break; } diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php index 603da1f5628e5bfb790842cd2303ef69a662bfd6..403c28c20c8da38607aacc57dc0b754c30e5eadd 100644 --- a/core/modules/taxonomy/src/Tests/TermTest.php +++ b/core/modules/taxonomy/src/Tests/TermTest.php @@ -255,7 +255,12 @@ function testNodeTermCreationAndDeletion() { // Save, creating the terms. $this->drupalPostForm('node/add/article', $edit, t('Save')); - $this->assertRaw(t('@type %title has been created.', array('@type' => t('Article'), '%title' => $edit['title[0][value]'])), 'The node was created successfully.'); + $this->assertText(t('@type @title has been created.', array('@type' => t('Article'), '@title' => $edit['title[0][value]'])), 'The node was created successfully.'); + + // Verify that the creation message contains a link to a node. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/')); + $this->assert(isset($view_link), 'The message area contains a link to a node'); + foreach ($terms as $term) { $this->assertText($term, 'The term was saved and appears on the node page.'); } diff --git a/core/modules/taxonomy/src/Tests/VocabularyPermissionsTest.php b/core/modules/taxonomy/src/Tests/VocabularyPermissionsTest.php index 5468f8a7a177d3f97e2c18225152f0a34ba28024..9a5e8c026ecdccfb4be74c9b655867df521a4809 100644 --- a/core/modules/taxonomy/src/Tests/VocabularyPermissionsTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyPermissionsTest.php @@ -36,7 +36,11 @@ function testVocabularyPermissionsTaxonomyTerm() { $edit['name[0][value]'] = $this->randomMachineName(); $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('Created new term %name.', array('%name' => $edit['name[0][value]'])), 'Term created successfully.'); + $this->assertText(t('Created new term @name.', array('@name' => $edit['name[0][value]'])), 'Term created successfully.'); + + // Verify that the creation message contains a link to a term. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'term/')); + $this->assert(isset($view_link), 'The message area contains a link to a term'); $terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']); $term = reset($terms); @@ -48,7 +52,7 @@ function testVocabularyPermissionsTaxonomyTerm() { $edit['name[0][value]'] = $this->randomMachineName(); $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('Updated term %name.', array('%name' => $edit['name[0][value]'])), 'Term updated successfully.'); + $this->assertText(t('Updated term @name.', array('@name' => $edit['name[0][value]'])), 'Term updated successfully.'); // Delete the vocabulary. $this->drupalGet('taxonomy/term/' . $term->id() . '/delete'); @@ -76,7 +80,11 @@ function testVocabularyPermissionsTaxonomyTerm() { $edit['name[0][value]'] = $this->randomMachineName(); $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('Updated term %name.', array('%name' => $edit['name[0][value]'])), 'Term updated successfully.'); + $this->assertText(t('Updated term @name.', array('@name' => $edit['name[0][value]'])), 'Term updated successfully.'); + + // Verify that the update message contains a link to a term. + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'term/')); + $this->assert(isset($view_link), 'The message area contains a link to a term'); // Delete the vocabulary. $this->drupalGet('taxonomy/term/' . $term->id() . '/delete');