diff --git a/core/modules/forum/tests/src/Functional/ForumTest.php b/core/modules/forum/tests/src/Functional/ForumTest.php index 76823a7..5ba28d9 100644 --- a/core/modules/forum/tests/src/Functional/ForumTest.php +++ b/core/modules/forum/tests/src/Functional/ForumTest.php @@ -301,13 +301,13 @@ private function doAdminTests($user) { $this->assertLink('Add forum'); $this->assertLink('Add container'); $this->clickLink('edit container'); - $this->assertRaw('Edit container', 'Followed the link to edit the container'); + $this->assertRaw('Edit ' . $this->forumContainer['name'], 'Followed the link to edit the container'); // Create forum inside the forum container. $this->forum = $this->createForum('forum', $this->forumContainer['tid']); // Verify the "edit forum" link exists and functions correctly. $this->drupalGet('admin/structure/forum'); $this->clickLink('edit forum'); - $this->assertRaw('Edit forum', 'Followed the link to edit the forum'); + $this->assertRaw('Edit ' . $this->forum['name'] . ' in Forums vocabulary', 'Followed the link to edit the forum'); // Navigate back to forum structure page. $this->drupalGet('admin/structure/forum'); // Create second forum in container, destined to be deleted below. @@ -404,11 +404,13 @@ public function createForum($type, $parent = 0) { $name = $this->randomMachineName(10); $description = $this->randomMachineName(100); + // Weight is set to -1, in order to have new added Forum as first in list, + // because that's expected by tests that use this method. $edit = [ 'name[0][value]' => $name, 'description[0][value]' => $description, 'parent[0]' => $parent, - 'weight' => '0', + 'weight' => '-1', ]; // Create forum. diff --git a/core/modules/taxonomy/src/TermForm.php b/core/modules/taxonomy/src/TermForm.php index 6e307ca..ceebd0c 100644 --- a/core/modules/taxonomy/src/TermForm.php +++ b/core/modules/taxonomy/src/TermForm.php @@ -4,6 +4,7 @@ use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Form\FormStateInterface; +use Drupal\taxonomy\Entity\Vocabulary; /** * Base for handler for taxonomy term edit forms. @@ -15,6 +16,12 @@ class TermForm extends ContentEntityForm { */ public function form(array $form, FormStateInterface $form_state) { $term = $this->entity; + + if (!$term->isNew()) { + $vocabulary = Vocabulary::load($term->bundle()); + $form['#title'] = $this->t('Edit @name in @parent vocabulary', array('@name' => $term->label(), '@parent' => $vocabulary->label())); + } + $vocab_storage = $this->entityManager->getStorage('taxonomy_vocabulary'); $taxonomy_storage = $this->entityManager->getStorage('taxonomy_term'); $vocabulary = $vocab_storage->load($term->bundle()); diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php index 42f92b1..d8a0eb4 100644 --- a/core/modules/taxonomy/src/Tests/TermTest.php +++ b/core/modules/taxonomy/src/Tests/TermTest.php @@ -325,6 +325,8 @@ public function testTermInterface() { $this->clickLink(t('Edit')); + $this->assertText('Edit ' . $edit['name[0][value]'] . ' in ' . $this->vocabulary->label() . ' vocabulary', 'Page title string contains term and vocabulary name.'); + $this->assertRaw($edit['name[0][value]'], 'The randomly generated term name is present.'); $this->assertText($edit['description[0][value]'], 'The randomly generated term description is present.'); diff --git a/core/modules/taxonomy/src/Tests/VocabularyUiTest.php b/core/modules/taxonomy/src/Tests/VocabularyUiTest.php index 89c7a67..a2bfb3f 100644 --- a/core/modules/taxonomy/src/Tests/VocabularyUiTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyUiTest.php @@ -51,6 +51,7 @@ public function testVocabularyInterface() { $this->assertText($edit['description'], 'Vocabulary description found in the vocabulary overview listing.'); $this->assertLinkByHref(Url::fromRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $edit['vid']])->toString()); $this->clickLink(t('Edit vocabulary')); + $this->assertRaw('Edit ' . $edit['name'], 'Page title string is formatted and contains vocabulary name.'); $edit = []; $edit['name'] = $this->randomMachineName(); $edit['description'] = $this->randomMachineName(); diff --git a/core/modules/taxonomy/src/VocabularyForm.php b/core/modules/taxonomy/src/VocabularyForm.php index 63f0ccb..3077396 100644 --- a/core/modules/taxonomy/src/VocabularyForm.php +++ b/core/modules/taxonomy/src/VocabularyForm.php @@ -49,7 +49,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Add vocabulary'); } else { - $form['#title'] = $this->t('Edit vocabulary'); + $form['#title'] = $this->t('Edit @name', array('@name' => $vocabulary->label())); } $form['name'] = [