diff -u b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php --- b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php @@ -6,6 +6,7 @@ use Drupal\Component\Render\MarkupInterface; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\comment\Entity\Comment; +use Drupal\Tests\TestFileCreationTrait; /** * Tests comment preview. @@ -14,6 +15,10 @@ */ class CommentPreviewTest extends CommentTestBase { + use TestFileCreationTrait { + getTestFiles as drupalGetTestFiles; + } + /** * The profile to install as a basis for testing. * @@ -105,16 +110,13 @@ $this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.'); // Store the content of this page. - $content = $this->getRawContent(); $this->drupalPostForm(NULL, [], 'Save'); $this->assertText('Your comment has been posted.'); $elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article'); $this->assertEqual(1, count($elements)); - // Reset the content of the page to simulate the browser's back button, and - // re-submit the form. - $this->setRawContent($content); - $this->drupalPostForm(NULL, [], 'Save'); + // Go back and re-submit the form. + $this->getSession()->getDriver()->back(); $this->assertText('Your comment has been posted.'); $elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article'); $this->assertEqual(2, count($elements)); diff -u b/core/modules/comment/tests/src/Functional/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php --- b/core/modules/comment/tests/src/Functional/CommentTestBase.php +++ b/core/modules/comment/src/Tests/CommentTestBase.php @@ -1,20 +1,24 @@ getSession()->getPage()->find('css', '.comment-wrapper ' . ($reply ? '.indented ' : '') . '#comment-' . $comment->id() . ' ~ article'); + $comment_element = $this->cssSelect('.comment-wrapper ' . ($reply ? '.indented ' : '') . '#comment-' . $comment->id() . ' ~ article'); if (empty($comment_element)) { return FALSE; } - $comment_title = $comment_element->find('xpath', 'div/h3/a'); - if (empty($comment_title) || $comment_title->getText() !== $comment->getSubject()) { + $comment_title = $comment_element[0]->xpath('div/h3/a'); + if (empty($comment_title) || ((string)$comment_title[0]) !== $comment->getSubject()) { return FALSE; } - $comment_body = $comment_element->find('xpath', 'div/div/p'); - if (empty($comment_body) || $comment_body->getText() !== $comment->comment_body->value) { + $comment_body = $comment_element[0]->xpath('div/div/p'); + if (empty($comment_body) || ((string)$comment_body[0]) !== $comment->comment_body->value) { return FALSE; } diff -u b/core/modules/comment/tests/src/Functional/Views/CommentTestBase.php b/core/modules/comment/src/Tests/Views/CommentTestBase.php --- b/core/modules/comment/tests/src/Functional/Views/CommentTestBase.php +++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php @@ -1,14 +1,18 @@ $langcode]); $view_url = $entity->url('canonical', ['language' => $language]); $elements = $this->xpath('//table//a[@href=:href]', [':href' => $view_url]); - $this->assertEqual($elements[0]->getText(), $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', ['%language' => $langcode])); + $this->assertEqual($elements[0]->getHtml(), $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', ['%language' => $langcode])); $edit_path = $entity->url('edit-form', ['language' => $language]); $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', [':href' => $edit_path]); - $this->assertEqual($elements[0]->getText(), t('Edit'), format_string('Edit link correct for %language translation.', ['%language' => $langcode])); + $this->assertEqual($elements[0]->getHtml(), t('Edit'), format_string('Edit link correct for %language translation.', ['%language' => $langcode])); } } } only in patch2: unchanged: --- a/core/modules/comment/src/Tests/CommentCSSTest.php +++ b/core/modules/comment/tests/src/Functional/CommentCSSTest.php @@ -1,6 +1,6 @@ array(0, 1), + * 'two' => array(2, 3), + * ); + * $permutations = TestBase::generatePermutations($parameters); + * // Result: + * $permutations == array( + * array('one' => 0, 'two' => 2), + * array('one' => 1, 'two' => 2), + * array('one' => 0, 'two' => 3), + * array('one' => 1, 'two' => 3), + * ) + * @endcode + * + * @param $parameters + * An associative array of parameters, keyed by parameter name, and whose + * values are arrays of parameter values. + * + * @return + * A list of permutations, which is an array of arrays. Each inner array + * contains the full list of parameters that have been passed, but with a + * single value only. + */ + public static function generatePermutations($parameters) { + $all_permutations = [[]]; + foreach ($parameters as $parameter => $values) { + $new_permutations = []; + // Iterate over all values of the parameter. + foreach ($values as $value) { + // Iterate over all existing permutations. + foreach ($all_permutations as $permutation) { + // Add the new parameter value to existing permutations. + $new_permutations[] = $permutation + [$parameter => $value]; + } + } + // Replace the old permutations with the new permutations. + $all_permutations = $new_permutations; + } + return $all_permutations; + } + }