diff --git a/core/modules/comment/src/Tests/CommentInterfaceTest.php b/core/modules/comment/src/Tests/CommentInterfaceTest.php index 137bcab..98eee30 100644 --- a/core/modules/comment/src/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/src/Tests/CommentInterfaceTest.php @@ -90,26 +90,6 @@ function testCommentInterface() { $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name' => $this->webUser->getUsername())); $this->assertTrue($comment->getAuthorName() == $this->webUser->getUsername() && $comment->getOwnerId() == $this->webUser->id(), 'Comment author successfully changed to a registered user.'); - // Test breadcrumb on comment add page. - $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); - $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; - $this->assertEqual(current($this->xpath($xpath)), $this->node->label(), 'Last breadcrumb item is equal to node title on comment reply page.'); - - // Test breadcrumb on comment reply page. - $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment->id()); - $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; - $this->assertEqual(current($this->xpath($xpath)), $comment->getSubject(), 'Last breadcrumb item is equal to comment title on comment reply page.'); - - // Test breadcrumb on comment edit page. - $this->drupalGet('comment/' . $comment->id() . '/edit'); - $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; - $this->assertEqual(current($this->xpath($xpath)), $comment->getSubject(), 'Last breadcrumb item is equal to comment subject on edit page.'); - - // Test breadcrumb on comment delete page. - $this->drupalGet('comment/' . $comment->id() . '/delete'); - $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; - $this->assertEqual(current($this->xpath($xpath)), $comment->getSubject(), 'Last breadcrumb item is equal to comment subject on delete confirm page.'); - $this->drupalLogout(); // Reply to comment #2 creating comment #3 with optional preview and no diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/src/Tests/CommentNonNodeTest.php index 9a9f48e..94d7e19 100644 --- a/core/modules/comment/src/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php @@ -35,6 +35,13 @@ class CommentNonNodeTest extends WebTestBase { protected $adminUser; /** + * The entity to use within tests. + * + * @var \Drupal\entity_test\Entity\EntityTest + */ + protected $entity; + + /** * {@inheritdoc} */ protected function setUp() { @@ -444,4 +451,29 @@ public function testsNonIntegerIdEntities() { $this->assertOption('edit-new-storage-type', 'boolean'); } + public function testBreadcrumbs() { + $this->drupalLogin($this->adminUser); + // Test breadcrumb on comment add page. + $this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment'); + $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; + $this->assertEqual(current($this->xpath($xpath)), $this->entity->label(), 'Last breadcrumb item is equal to node title on comment reply page.'); + + /** @var \Drupal\comment\CommentInterface $comment */ + $comment = $this->postComment($this->entity, $this->randomMachineName(), $this->randomMachineName()); + // Test breadcrumb on comment reply page. + $this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment/' . $comment->id()); + $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; + $this->assertEqual(current($this->xpath($xpath)), $comment->getSubject(), 'Last breadcrumb item is equal to comment title on comment reply page.'); + + // Test breadcrumb on comment edit page. + $this->drupalGet('comment/' . $comment->id() . '/edit'); + $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; + $this->assertEqual(current($this->xpath($xpath)), $comment->getSubject(), 'Last breadcrumb item is equal to comment subject on edit page.'); + + // Test breadcrumb on comment delete page. + $this->drupalGet('comment/' . $comment->id() . '/delete'); + $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; + $this->assertEqual(current($this->xpath($xpath)), $comment->getSubject(), 'Last breadcrumb item is equal to comment subject on delete confirm page.'); + } + }