comparison core/modules/comment/tests/src/Functional/CommentBlockTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests\comment\Functional; 3 namespace Drupal\Tests\comment\Functional;
4 4
5 use Drupal\Component\Utility\SafeMarkup; 5 use Drupal\Component\Render\FormattableMarkup;
6 use Drupal\user\RoleInterface; 6 use Drupal\user\RoleInterface;
7 7
8 /** 8 /**
9 * Tests comment block functionality. 9 * Tests comment block functionality.
10 * 10 *
66 $this->assertText(t('Recent comments')); 66 $this->assertText(t('Recent comments'));
67 67
68 // Test the only the 10 latest comments are shown and in the proper order. 68 // Test the only the 10 latest comments are shown and in the proper order.
69 $this->assertNoText($comments[10]->getSubject(), 'Comment 11 not found in block.'); 69 $this->assertNoText($comments[10]->getSubject(), 'Comment 11 not found in block.');
70 for ($i = 0; $i < 10; $i++) { 70 for ($i = 0; $i < 10; $i++) {
71 $this->assertText($comments[$i]->getSubject(), SafeMarkup::format('Comment @number found in block.', ['@number' => 10 - $i])); 71 $this->assertText($comments[$i]->getSubject(), new FormattableMarkup('Comment @number found in block.', ['@number' => 10 - $i]));
72 if ($i > 1) { 72 if ($i > 1) {
73 $previous_position = $position; 73 $previous_position = $position;
74 $position = strpos($this->getRawContent(), $comments[$i]->getSubject()); 74 $position = strpos($this->getSession()->getPage()->getContent(), $comments[$i]->getSubject());
75 $this->assertTrue($position > $previous_position, SafeMarkup::format('Comment @a appears after comment @b', ['@a' => 10 - $i, '@b' => 11 - $i])); 75 $this->assertTrue($position > $previous_position, new FormattableMarkup('Comment @a appears after comment @b', ['@a' => 10 - $i, '@b' => 11 - $i]));
76 } 76 }
77 $position = strpos($this->getRawContent(), $comments[$i]->getSubject()); 77 $position = strpos($this->getSession()->getPage()->getContent(), $comments[$i]->getSubject());
78 } 78 }
79 79
80 // Test that links to comments work when comments are across pages. 80 // Test that links to comments work when comments are across pages.
81 $this->setCommentsPerPage(1); 81 $this->setCommentsPerPage(1);
82 82