summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/modules/comment/src/Tests/CommentTestBase.php7
-rw-r--r--core/modules/comment/src/Tests/Views/CommentTestBase.php9
-rw-r--r--core/modules/comment/tests/src/Functional/CommentActionsTest.php (renamed from core/modules/comment/src/Tests/CommentActionsTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentAdminTest.php (renamed from core/modules/comment/src/Tests/CommentAdminTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentAnonymousTest.php (renamed from core/modules/comment/src/Tests/CommentAnonymousTest.php)6
-rw-r--r--core/modules/comment/tests/src/Functional/CommentBlockTest.php (renamed from core/modules/comment/src/Tests/CommentBlockTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentBookTest.php (renamed from core/modules/comment/src/Tests/CommentBookTest.php)7
-rw-r--r--core/modules/comment/tests/src/Functional/CommentCSSTest.php (renamed from core/modules/comment/src/Tests/CommentCSSTest.php)5
-rw-r--r--core/modules/comment/tests/src/Functional/CommentFieldsTest.php (renamed from core/modules/comment/src/Tests/CommentFieldsTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentInterfaceTest.php (renamed from core/modules/comment/src/Tests/CommentInterfaceTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentLanguageTest.php (renamed from core/modules/comment/src/Tests/CommentLanguageTest.php)7
-rw-r--r--core/modules/comment/tests/src/Functional/CommentLinksAlterTest.php (renamed from core/modules/comment/src/Tests/CommentLinksAlterTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentLinksTest.php (renamed from core/modules/comment/src/Tests/CommentLinksTest.php)10
-rw-r--r--core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php (renamed from core/modules/comment/src/Tests/CommentNodeAccessTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentNodeChangesTest.php (renamed from core/modules/comment/src/Tests/CommentNodeChangesTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentNonNodeTest.php (renamed from core/modules/comment/src/Tests/CommentNonNodeTest.php)15
-rw-r--r--core/modules/comment/tests/src/Functional/CommentPreviewTest.php (renamed from core/modules/comment/src/Tests/CommentPreviewTest.php)24
-rw-r--r--core/modules/comment/tests/src/Functional/CommentRssTest.php (renamed from core/modules/comment/src/Tests/CommentRssTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentStatisticsTest.php (renamed from core/modules/comment/src/Tests/CommentStatisticsTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentTestBase.php402
-rw-r--r--core/modules/comment/tests/src/Functional/CommentThreadingTest.php (renamed from core/modules/comment/src/Tests/CommentThreadingTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentTitleTest.php (renamed from core/modules/comment/src/Tests/CommentTitleTest.php)4
-rw-r--r--core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php (renamed from core/modules/comment/src/Tests/CommentTokenReplaceTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentTranslationUITest.php (renamed from core/modules/comment/src/Tests/CommentTranslationUITest.php)5
-rw-r--r--core/modules/comment/tests/src/Functional/CommentTypeTest.php (renamed from core/modules/comment/src/Tests/CommentTypeTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/CommentUninstallTest.php (renamed from core/modules/comment/src/Tests/CommentUninstallTest.php)7
-rw-r--r--core/modules/comment/tests/src/Functional/Views/ArgumentUserUIDTest.php (renamed from core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php (renamed from core/modules/comment/src/Tests/Views/CommentAdminTest.php)6
-rw-r--r--core/modules/comment/tests/src/Functional/Views/CommentEditTest.php (renamed from core/modules/comment/src/Tests/Views/CommentEditTest.php)8
-rw-r--r--core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php (renamed from core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php)6
-rw-r--r--core/modules/comment/tests/src/Functional/Views/CommentFieldNameTest.php (renamed from core/modules/comment/src/Tests/Views/CommentFieldNameTest.php)6
-rw-r--r--core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php (renamed from core/modules/comment/src/Tests/Views/CommentOperationsTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php (renamed from core/modules/comment/src/Tests/Views/CommentRestExportTest.php)8
-rw-r--r--core/modules/comment/tests/src/Functional/Views/CommentRowTest.php (renamed from core/modules/comment/src/Tests/Views/CommentRowTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/Views/CommentTestBase.php90
-rw-r--r--core/modules/comment/tests/src/Functional/Views/DefaultViewRecentCommentsTest.php (renamed from core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php)8
-rw-r--r--core/modules/comment/tests/src/Functional/Views/FilterUserUIDTest.php (renamed from core/modules/comment/src/Tests/Views/FilterUserUIDTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/Views/NodeCommentsTest.php (renamed from core/modules/comment/src/Tests/Views/NodeCommentsTest.php)2
-rw-r--r--core/modules/comment/tests/src/Functional/Views/RowRssTest.php (renamed from core/modules/comment/src/Tests/Views/RowRssTest.php)8
-rw-r--r--core/modules/comment/tests/src/Functional/Views/WizardTest.php (renamed from core/modules/comment/src/Tests/Views/WizardTest.php)10
40 files changed, 606 insertions, 88 deletions
diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php
index 6967fdd..1b0f959 100644
--- a/core/modules/comment/src/Tests/CommentTestBase.php
+++ b/core/modules/comment/src/Tests/CommentTestBase.php
@@ -2,6 +2,8 @@
namespace Drupal\comment\Tests;
+@trigger_error(__NAMESPACE__ . '\CommentTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\Tests\comment\Functional\CommentTestBase instead. See http://www.drupal.org/node/2908490', E_USER_DEPRECATED);
+
use Drupal\comment\Entity\CommentType;
use Drupal\comment\Entity\Comment;
use Drupal\comment\CommentInterface;
@@ -12,6 +14,11 @@ use Drupal\simpletest\WebTestBase;
/**
* Provides setup and helper methods for comment tests.
+ *
+ * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0.
+ * Use \Drupal\Tests\comment\Functional\CommentTestBase instead.
+ *
+ * @see https://www.drupal.org/node/2908490
*/
abstract class CommentTestBase extends WebTestBase {
diff --git a/core/modules/comment/src/Tests/Views/CommentTestBase.php b/core/modules/comment/src/Tests/Views/CommentTestBase.php
index d7bec04..3d10858 100644
--- a/core/modules/comment/src/Tests/Views/CommentTestBase.php
+++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php
@@ -2,13 +2,20 @@
namespace Drupal\comment\Tests\Views;
+@trigger_error(__NAMESPACE__ . '\CommentTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\Tests\comment\Functional\Views\CommentTestBase instead. See http://www.drupal.org/node/2908490', E_USER_DEPRECATED);
+
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\comment\Entity\Comment;
/**
- * Tests the argument_comment_user_uid handler.
+ * Provides setup and helper methods for comment views tests.
+ *
+ * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0.
+ * Use \Drupal\Tests\comment\Functional\Views\CommentTestBase instead.
+ *
+ * @see https://www.drupal.org/node/2908490
*/
abstract class CommentTestBase extends ViewTestBase {
diff --git a/core/modules/comment/src/Tests/CommentActionsTest.php b/core/modules/comment/tests/src/Functional/CommentActionsTest.php
index 56d34e4..79786fc 100644
--- a/core/modules/comment/src/Tests/CommentActionsTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentActionsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\Entity\Comment;
use Drupal\system\Entity\Action;
diff --git a/core/modules/comment/src/Tests/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/CommentAdminTest.php
index 7c4aae0..93cff3c 100644
--- a/core/modules/comment/src/Tests/CommentAdminTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
diff --git a/core/modules/comment/src/Tests/CommentAnonymousTest.php b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
index d60c073..bd04537 100644
--- a/core/modules/comment/src/Tests/CommentAnonymousTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\user\RoleInterface;
@@ -43,7 +43,7 @@ class CommentAnonymousTest extends CommentTestBase {
$edit['comment_body[0][value]'] = $body;
$this->drupalPostForm($this->node->urlInfo(), $edit, t('Preview'));
// Cannot use assertRaw here since both title and body are in the form.
- $preview = (string) $this->cssSelect('.preview')[0]->asXML();
+ $preview = (string) $this->cssSelect('.preview')[0]->getHtml();
$this->assertTrue(strpos($preview, $title) !== FALSE, 'Anonymous user can preview comment title.');
$this->assertTrue(strpos($preview, $body) !== FALSE, 'Anonymous user can preview comment body.');
@@ -56,7 +56,7 @@ class CommentAnonymousTest extends CommentTestBase {
$edit['comment_body[0][value]'] = $body;
$this->drupalPostForm($this->node->urlInfo(), $edit, t('Preview'));
// Cannot use assertRaw here since both title and body are in the form.
- $preview = (string) $this->cssSelect('.preview')[0]->asXML();
+ $preview = (string) $this->cssSelect('.preview')[0]->getHtml();
$this->assertTrue(strpos($preview, $title) !== FALSE, 'Anonymous user can preview comment title.');
$this->assertTrue(strpos($preview, $body) !== FALSE, 'Anonymous user can preview comment body.');
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['skip comment approval']);
diff --git a/core/modules/comment/src/Tests/CommentBlockTest.php b/core/modules/comment/tests/src/Functional/CommentBlockTest.php
index 37cc5de..db7d1bd 100644
--- a/core/modules/comment/src/Tests/CommentBlockTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentBlockTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\user\RoleInterface;
diff --git a/core/modules/comment/src/Tests/CommentBookTest.php b/core/modules/comment/tests/src/Functional/CommentBookTest.php
index 4afd07e..45693b5 100644
--- a/core/modules/comment/src/Tests/CommentBookTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentBookTest.php
@@ -1,10 +1,11 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\CommentInterface;
+use Drupal\comment\Tests\CommentTestTrait;
use Drupal\node\Entity\Node;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
use Drupal\comment\Entity\Comment;
/**
@@ -12,7 +13,7 @@ use Drupal\comment\Entity\Comment;
*
* @group comment
*/
-class CommentBookTest extends WebTestBase {
+class CommentBookTest extends BrowserTestBase {
use CommentTestTrait;
diff --git a/core/modules/comment/src/Tests/CommentCSSTest.php b/core/modules/comment/tests/src/Functional/CommentCSSTest.php
index b50e952..e17534a 100644
--- a/core/modules/comment/src/Tests/CommentCSSTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentCSSTest.php
@@ -1,11 +1,12 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\Core\Language\LanguageInterface;
use Drupal\comment\CommentInterface;
use Drupal\user\RoleInterface;
use Drupal\comment\Entity\Comment;
+use Drupal\Tests\Traits\Core\GeneratePermutationsTrait;
/**
* Tests CSS classes on comments.
@@ -14,6 +15,8 @@ use Drupal\comment\Entity\Comment;
*/
class CommentCSSTest extends CommentTestBase {
+ use GeneratePermutationsTrait;
+
protected function setUp() {
parent::setUp();
diff --git a/core/modules/comment/src/Tests/CommentFieldsTest.php b/core/modules/comment/tests/src/Functional/CommentFieldsTest.php
index a463314..2df9973 100644
--- a/core/modules/comment/src/Tests/CommentFieldsTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentFieldsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\field\Entity\FieldStorageConfig;
diff --git a/core/modules/comment/src/Tests/CommentInterfaceTest.php b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php
index 6f67ca8..7342633 100644
--- a/core/modules/comment/src/Tests/CommentInterfaceTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\CommentManagerInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
diff --git a/core/modules/comment/src/Tests/CommentLanguageTest.php b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php
index eee0862..ce9a9ab 100644
--- a/core/modules/comment/src/Tests/CommentLanguageTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php
@@ -1,18 +1,19 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
+use Drupal\comment\Tests\CommentTestTrait;
use Drupal\field\Entity\FieldStorageConfig;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
/**
* Tests for comment language.
*
* @group comment
*/
-class CommentLanguageTest extends WebTestBase {
+class CommentLanguageTest extends BrowserTestBase {
use CommentTestTrait;
diff --git a/core/modules/comment/src/Tests/CommentLinksAlterTest.php b/core/modules/comment/tests/src/Functional/CommentLinksAlterTest.php
index 88e092f..e49361b 100644
--- a/core/modules/comment/src/Tests/CommentLinksAlterTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentLinksAlterTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
/**
* Tests comment links altering.
diff --git a/core/modules/comment/src/Tests/CommentLinksTest.php b/core/modules/comment/tests/src/Functional/CommentLinksTest.php
index 589a355..3d79d96 100644
--- a/core/modules/comment/src/Tests/CommentLinksTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentLinksTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Language\LanguageInterface;
@@ -108,8 +108,8 @@ class CommentLinksTest extends CommentTestBase {
$this->drupalGet($this->node->urlInfo());
$element = $this->cssSelect('article.js-comment > div');
// Get last child element.
- $element = end($element[0]);
- $this->assertIdentical($element[0]->getName(), 'div', 'Last element is comment body.');
+ $element = end($element);
+ $this->assertIdentical($element->getTagName(), 'div', 'Last element is comment body.');
// Change weight to make links go after comment body.
entity_get_display('comment', 'comment', 'default')
@@ -118,8 +118,8 @@ class CommentLinksTest extends CommentTestBase {
$this->drupalGet($this->node->urlInfo());
$element = $this->cssSelect('article.js-comment > div');
// Get last child element.
- $element = end($element[0]);
- $this->assertIdentical($element[0]->getName(), 'ul', 'Last element is comment links.');
+ $element = end($element);
+ $this->assertNotEmpty($element->find('css', 'ul.links'), 'Last element is comment links.');
// Make sure we can hide node links.
entity_get_display('node', $this->node->bundle(), 'default')
diff --git a/core/modules/comment/src/Tests/CommentNodeAccessTest.php b/core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php
index ffbffa1..6842dc1 100644
--- a/core/modules/comment/src/Tests/CommentNodeAccessTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\CommentManagerInterface;
diff --git a/core/modules/comment/src/Tests/CommentNodeChangesTest.php b/core/modules/comment/tests/src/Functional/CommentNodeChangesTest.php
index 148198d..a63ce8b 100644
--- a/core/modules/comment/src/Tests/CommentNodeChangesTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentNodeChangesTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\Entity\Comment;
use Drupal\field\Entity\FieldConfig;
diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
index d01486d..257b733 100644
--- a/core/modules/comment/src/Tests/CommentNonNodeTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
@@ -1,16 +1,17 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Entity\CommentType;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
+use Drupal\comment\Tests\CommentTestTrait;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field_ui\Tests\FieldUiTestTrait;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
use Drupal\Core\Entity\EntityInterface;
use Drupal\user\RoleInterface;
@@ -19,7 +20,7 @@ use Drupal\user\RoleInterface;
*
* @group comment
*/
-class CommentNonNodeTest extends WebTestBase {
+class CommentNonNodeTest extends BrowserTestBase {
use FieldUiTestTrait;
use CommentTestTrait;
@@ -273,7 +274,7 @@ class CommentNonNodeTest extends WebTestBase {
// 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.');
+ $this->assertEqual(current($this->xpath($xpath))->getText(), $this->entity->label(), 'Last breadcrumb item is equal to node title on comment reply page.');
// Post a comment.
/** @var \Drupal\comment\CommentInterface $comment1 */
@@ -283,17 +284,17 @@ class CommentNonNodeTest extends WebTestBase {
// Test breadcrumb on comment reply page.
$this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment/' . $comment1->id());
$xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a';
- $this->assertEqual(current($this->xpath($xpath)), $comment1->getSubject(), 'Last breadcrumb item is equal to comment title on comment reply page.');
+ $this->assertEqual(current($this->xpath($xpath))->getText(), $comment1->getSubject(), 'Last breadcrumb item is equal to comment title on comment reply page.');
// Test breadcrumb on comment edit page.
$this->drupalGet('comment/' . $comment1->id() . '/edit');
$xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a';
- $this->assertEqual(current($this->xpath($xpath)), $comment1->getSubject(), 'Last breadcrumb item is equal to comment subject on edit page.');
+ $this->assertEqual(current($this->xpath($xpath))->getText(), $comment1->getSubject(), 'Last breadcrumb item is equal to comment subject on edit page.');
// Test breadcrumb on comment delete page.
$this->drupalGet('comment/' . $comment1->id() . '/delete');
$xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a';
- $this->assertEqual(current($this->xpath($xpath)), $comment1->getSubject(), 'Last breadcrumb item is equal to comment subject on delete confirm page.');
+ $this->assertEqual(current($this->xpath($xpath))->getText(), $comment1->getSubject(), 'Last breadcrumb item is equal to comment subject on delete confirm page.');
// Unpublish the comment.
$this->performCommentOperation($comment1, 'unpublish');
diff --git a/core/modules/comment/src/Tests/CommentPreviewTest.php b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php
index 1b07fe6..89ac668 100644
--- a/core/modules/comment/src/Tests/CommentPreviewTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php
@@ -1,11 +1,12 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\CommentManagerInterface;
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 @@ use Drupal\comment\Entity\Comment;
*/
class CommentPreviewTest extends CommentTestBase {
+ use TestFileCreationTrait {
+ getTestFiles as drupalGetTestFiles;
+ }
+
/**
* The profile to install as a basis for testing.
*
@@ -105,16 +110,13 @@ class CommentPreviewTest extends CommentTestBase {
$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));
@@ -173,11 +175,11 @@ class CommentPreviewTest extends CommentTestBase {
// Submit the form using the displayed values.
$displayed = [];
- $displayed['subject[0][value]'] = (string) current($this->xpath("//input[@id='edit-subject-0-value']/@value"));
- $displayed['comment_body[0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-0-value']"));
- $displayed['uid'] = (string) current($this->xpath("//input[@id='edit-uid']/@value"));
- $displayed['date[date]'] = (string) current($this->xpath("//input[@id='edit-date-date']/@value"));
- $displayed['date[time]'] = (string) current($this->xpath("//input[@id='edit-date-time']/@value"));
+ $displayed['subject[0][value]'] = current($this->xpath("//input[@id='edit-subject-0-value']"))->getValue();
+ $displayed['comment_body[0][value]'] = current($this->xpath("//textarea[@id='edit-comment-body-0-value']"))->getValue();
+ $displayed['uid'] = current($this->xpath("//input[@id='edit-uid']"))->getValue();
+ $displayed['date[date]'] = current($this->xpath("//input[@id='edit-date-date']"))->getValue();
+ $displayed['date[time]'] = current($this->xpath("//input[@id='edit-date-time']"))->getValue();
$this->drupalPostForm('comment/' . $comment->id() . '/edit', $displayed, t('Save'));
// Check that the saved comment is still correct.
diff --git a/core/modules/comment/src/Tests/CommentRssTest.php b/core/modules/comment/tests/src/Functional/CommentRssTest.php
index 35cad71..60708bd 100644
--- a/core/modules/comment/src/Tests/CommentRssTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentRssTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Cache\Cache;
diff --git a/core/modules/comment/src/Tests/CommentStatisticsTest.php b/core/modules/comment/tests/src/Functional/CommentStatisticsTest.php
index 0d1ec3a..4a0eae0 100644
--- a/core/modules/comment/src/Tests/CommentStatisticsTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentStatisticsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\CommentManagerInterface;
use Drupal\comment\Entity\Comment;
diff --git a/core/modules/comment/tests/src/Functional/CommentTestBase.php b/core/modules/comment/tests/src/Functional/CommentTestBase.php
new file mode 100644
index 0000000..97ba9d5
--- /dev/null
+++ b/core/modules/comment/tests/src/Functional/CommentTestBase.php
@@ -0,0 +1,402 @@
+<?php
+
+namespace Drupal\Tests\comment\Functional;
+
+use Drupal\comment\Entity\CommentType;
+use Drupal\comment\Entity\Comment;
+use Drupal\comment\CommentInterface;
+use Drupal\comment\Tests\CommentTestTrait;
+use Drupal\field\Entity\FieldConfig;
+use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
+use Drupal\node\Entity\NodeType;
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Provides setup and helper methods for comment tests.
+ */
+abstract class CommentTestBase extends BrowserTestBase {
+
+ use CommentTestTrait;
+
+ /**
+ * Modules to install.
+ *
+ * @var array
+ */
+ public static $modules = ['block', 'comment', 'node', 'history', 'field_ui', 'datetime'];
+
+ /**
+ * An administrative user with permission to configure comment settings.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $adminUser;
+
+ /**
+ * A normal user with permission to post comments.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $webUser;
+
+ /**
+ * A test node to which comments will be posted.
+ *
+ * @var \Drupal\node\NodeInterface
+ */
+ protected $node;
+
+ protected function setUp() {
+ parent::setUp();
+
+ // Create an article content type only if it does not yet exist, so that
+ // child classes may specify the standard profile.
+ $types = NodeType::loadMultiple();
+ if (empty($types['article'])) {
+ $this->drupalCreateContentType(['type' => 'article', 'name' => t('Article')]);
+ }
+
+ // Create two test users.
+ $this->adminUser = $this->drupalCreateUser([
+ 'administer content types',
+ 'administer comments',
+ 'administer comment types',
+ 'administer comment fields',
+ 'administer comment display',
+ 'skip comment approval',
+ 'post comments',
+ 'access comments',
+ // Usernames aren't shown in comment edit form autocomplete unless this
+ // permission is granted.
+ 'access user profiles',
+ 'access content',
+ ]);
+ $this->webUser = $this->drupalCreateUser([
+ 'access comments',
+ 'post comments',
+ 'create article content',
+ 'edit own comments',
+ 'skip comment approval',
+ 'access content',
+ ]);
+
+ // Create comment field on article.
+ $this->addDefaultCommentField('node', 'article');
+
+ // Create a test node authored by the web user.
+ $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]);
+ $this->drupalPlaceBlock('local_tasks_block');
+ }
+
+ /**
+ * Posts a comment.
+ *
+ * @param \Drupal\Core\Entity\EntityInterface|null $entity
+ * Node to post comment on or NULL to post to the previously loaded page.
+ * @param string $comment
+ * Comment body.
+ * @param string $subject
+ * Comment subject.
+ * @param string $contact
+ * Set to NULL for no contact info, TRUE to ignore success checking, and
+ * array of values to set contact info.
+ * @param string $field_name
+ * (optional) Field name through which the comment should be posted.
+ * Defaults to 'comment'.
+ *
+ * @return \Drupal\comment\CommentInterface|null
+ * The posted comment or NULL when posted comment was not found.
+ */
+ public function postComment($entity, $comment, $subject = '', $contact = NULL, $field_name = 'comment') {
+ $edit = [];
+ $edit['comment_body[0][value]'] = $comment;
+
+ if ($entity !== NULL) {
+ $field = FieldConfig::loadByName($entity->getEntityTypeId(), $entity->bundle(), $field_name);
+ }
+ else {
+ $field = FieldConfig::loadByName('node', 'article', $field_name);
+ }
+ $preview_mode = $field->getSetting('preview');
+
+ // Must get the page before we test for fields.
+ if ($entity !== NULL) {
+ $this->drupalGet('comment/reply/' . $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $field_name);
+ }
+
+ // Determine the visibility of subject form field.
+ if (entity_get_form_display('comment', 'comment', 'default')->getComponent('subject')) {
+ // Subject input allowed.
+ $edit['subject[0][value]'] = $subject;
+ }
+ else {
+ $this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.');
+ }
+
+ if ($contact !== NULL && is_array($contact)) {
+ $edit += $contact;
+ }
+ switch ($preview_mode) {
+ case DRUPAL_REQUIRED:
+ // Preview required so no save button should be found.
+ $this->assertNoFieldByName('op', t('Save'), 'Save button not found.');
+ $this->drupalPostForm(NULL, $edit, t('Preview'));
+ // Don't break here so that we can test post-preview field presence and
+ // function below.
+ case DRUPAL_OPTIONAL:
+ $this->assertFieldByName('op', t('Preview'), 'Preview button found.');
+ $this->assertFieldByName('op', t('Save'), 'Save button found.');
+ $this->drupalPostForm(NULL, $edit, t('Save'));
+ break;
+
+ case DRUPAL_DISABLED:
+ $this->assertNoFieldByName('op', t('Preview'), 'Preview button not found.');
+ $this->assertFieldByName('op', t('Save'), 'Save button found.');
+ $this->drupalPostForm(NULL, $edit, t('Save'));
+ break;
+ }
+ $match = [];
+ // Get comment ID
+ preg_match('/#comment-([0-9]+)/', $this->getURL(), $match);
+
+ // Get comment.
+ if ($contact !== TRUE) {// If true then attempting to find error message.
+ if ($subject) {
+ $this->assertText($subject, 'Comment subject posted.');
+ }
+ $this->assertText($comment, 'Comment body posted.');
+ $this->assertTrue((!empty($match) && !empty($match[1])), 'Comment id found.');
+ }
+
+ if (isset($match[1])) {
+ \Drupal::entityManager()->getStorage('comment')->resetCache([$match[1]]);
+ return Comment::load($match[1]);
+ }
+ }
+
+ /**
+ * Checks current page for specified comment.
+ *
+ * @param \Drupal\comment\CommentInterface $comment
+ * The comment object.
+ * @param bool $reply
+ * Boolean indicating whether the comment is a reply to another comment.
+ *
+ * @return bool
+ * Boolean indicating whether the comment was found.
+ */
+ public function commentExists(CommentInterface $comment = NULL, $reply = FALSE) {
+ if ($comment) {
+ $comment_element = $this->cssSelect('.comment-wrapper ' . ($reply ? '.indented ' : '') . '#comment-' . $comment->id() . ' ~ article');
+ if (empty($comment_element)) {
+ return FALSE;
+ }
+
+ $comment_title = $comment_element[0]->find('xpath', 'div/h3/a');
+ if (empty($comment_title) || $comment_title->getText() !== $comment->getSubject()) {
+ return FALSE;
+ }
+
+ $comment_body = $comment_element[0]->find('xpath', 'div/div/p');
+ if (empty($comment_body) || $comment_body->getText() !== $comment->comment_body->value) {
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+
+ /**
+ * Deletes a comment.
+ *
+ * @param \Drupal\comment\CommentInterface $comment
+ * Comment to delete.
+ */
+ public function deleteComment(CommentInterface $comment) {
+ $this->drupalPostForm('comment/' . $comment->id() . '/delete', [], t('Delete'));
+ $this->assertText(t('The comment and all its replies have been deleted.'), 'Comment deleted.');
+ }
+
+ /**
+ * Sets the value governing whether the subject field should be enabled.
+ *
+ * @param bool $enabled
+ * Boolean specifying whether the subject field should be enabled.
+ */
+ public function setCommentSubject($enabled) {
+ $form_display = entity_get_form_display('comment', 'comment', 'default');
+ if ($enabled) {
+ $form_display->setComponent('subject', [
+ 'type' => 'string_textfield',
+ ]);
+ }
+ else {
+ $form_display->removeComponent('subject');
+ }
+ $form_display->save();
+ // Display status message.
+ $this->pass('Comment subject ' . ($enabled ? 'enabled' : 'disabled') . '.');
+ }
+
+ /**
+ * Sets the value governing the previewing mode for the comment form.
+ *
+ * @param int $mode
+ * The preview mode: DRUPAL_DISABLED, DRUPAL_OPTIONAL or DRUPAL_REQUIRED.
+ * @param string $field_name
+ * (optional) Field name through which the comment should be posted.
+ * Defaults to 'comment'.
+ */
+ public function setCommentPreview($mode, $field_name = 'comment') {
+ switch ($mode) {
+ case DRUPAL_DISABLED:
+ $mode_text = 'disabled';
+ break;
+
+ case DRUPAL_OPTIONAL:
+ $mode_text = 'optional';
+ break;
+
+ case DRUPAL_REQUIRED:
+ $mode_text = 'required';
+ break;
+ }
+ $this->setCommentSettings('preview', $mode, format_string('Comment preview @mode_text.', ['@mode_text' => $mode_text]), $field_name);
+ }
+
+ /**
+ * Sets the value governing whether the comment form is on its own page.
+ *
+ * @param bool $enabled
+ * TRUE if the comment form should be displayed on the same page as the
+ * comments; FALSE if it should be displayed on its own page.
+ * @param string $field_name
+ * (optional) Field name through which the comment should be posted.
+ * Defaults to 'comment'.
+ */
+ public function setCommentForm($enabled, $field_name = 'comment') {
+ $this->setCommentSettings('form_location', ($enabled ? CommentItemInterface::FORM_BELOW : CommentItemInterface::FORM_SEPARATE_PAGE), 'Comment controls ' . ($enabled ? 'enabled' : 'disabled') . '.', $field_name);
+ }
+
+ /**
+ * Sets the value governing restrictions on anonymous comments.
+ *
+ * @param int $level
+ * The level of the contact information allowed for anonymous comments:
+ * - 0: No contact information allowed.
+ * - 1: Contact information allowed but not required.
+ * - 2: Contact information required.
+ */
+ public function setCommentAnonymous($level) {
+ $this->setCommentSettings('anonymous', $level, format_string('Anonymous commenting set to level @level.', ['@level' => $level]));
+ }
+
+ /**
+ * Sets the value specifying the default number of comments per page.
+ *
+ * @param int $number
+ * Comments per page value.
+ * @param string $field_name
+ * (optional) Field name through which the comment should be posted.
+ * Defaults to 'comment'.
+ */
+ public function setCommentsPerPage($number, $field_name = 'comment') {
+ $this->setCommentSettings('per_page', $number, format_string('Number of comments per page set to @number.', ['@number' => $number]), $field_name);
+ }
+
+ /**
+ * Sets a comment settings variable for the article content type.
+ *
+ * @param string $name
+ * Name of variable.
+ * @param string $value
+ * Value of variable.
+ * @param string $message
+ * Status message to display.
+ * @param string $field_name
+ * (optional) Field name through which the comment should be posted.
+ * Defaults to 'comment'.
+ */
+ public function setCommentSettings($name, $value, $message, $field_name = 'comment') {
+ $field = FieldConfig::loadByName('node', 'article', $field_name);
+ $field->setSetting($name, $value);
+ $field->save();
+ // Display status message.
+ $this->pass($message);
+ }
+
+ /**
+ * Checks whether the commenter's contact information is displayed.
+ *
+ * @return bool
+ * Contact info is available.
+ */
+ public function commentContactInfoAvailable() {
+ return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->getRawContent());
+ }
+
+ /**
+ * Performs the specified operation on the specified comment.
+ *
+ * @param \Drupal\comment\CommentInterface $comment
+ * Comment to perform operation on.
+ * @param string $operation
+ * Operation to perform.
+ * @param bool $approval
+ * Operation is found on approval page.
+ */
+ public function performCommentOperation(CommentInterface $comment, $operation, $approval = FALSE) {
+ $edit = [];
+ $edit['operation'] = $operation;
+ $edit['comments[' . $comment->id() . ']'] = TRUE;
+ $this->drupalPostForm('admin/content/comment' . ($approval ? '/approval' : ''), $edit, t('Update'));
+
+ if ($operation == 'delete') {
+ $this->drupalPostForm(NULL, [], t('Delete'));
+ $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
+ }
+ else {
+ $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
+ }
+ }
+
+ /**
+ * Gets the comment ID for an unapproved comment.
+ *
+ * @param string $subject
+ * Comment subject to find.
+ *
+ * @return int
+ * Comment id.
+ */
+ public function getUnapprovedComment($subject) {
+ $this->drupalGet('admin/content/comment/approval');
+ preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->getRawContent(), $match);
+
+ return $match[2];
+ }
+
+ /**
+ * Creates a comment comment type (bundle).
+ *
+ * @param string $label
+ * The comment type label.
+ *
+ * @return \Drupal\comment\Entity\CommentType
+ * Created comment type.
+ */
+ protected function createCommentType($label) {
+ $bundle = CommentType::create([
+ 'id' => $label,
+ 'label' => $label,
+ 'description' => '',
+ 'target_entity_type_id' => 'node',
+ ]);
+ $bundle->save();
+ return $bundle;
+ }
+
+}
diff --git a/core/modules/comment/src/Tests/CommentThreadingTest.php b/core/modules/comment/tests/src/Functional/CommentThreadingTest.php
index 8f412b2..cff22ba 100644
--- a/core/modules/comment/src/Tests/CommentThreadingTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentThreadingTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\CommentManagerInterface;
diff --git a/core/modules/comment/src/Tests/CommentTitleTest.php b/core/modules/comment/tests/src/Functional/CommentTitleTest.php
index 1d24ad8..65c4937 100644
--- a/core/modules/comment/src/Tests/CommentTitleTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTitleTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
/**
* Tests to ensure that appropriate and accessible markup is created for comment
@@ -73,7 +73,7 @@ class CommentTitleTest extends CommentTestBase {
$this->assertPattern('|<h3[^>]*><a[^>]*>' . $subject_text . '</a></h3>|', 'Comment title is rendered in h3 when title populated.');
// Tests that the comment's title link is the permalink of the comment.
$comment_permalink = $this->cssSelect('.permalink');
- $comment_permalink = (string) $comment_permalink[0]['href'];
+ $comment_permalink = $comment_permalink[0]->getAttribute('href');
// Tests that the comment's title link contains the url fragment.
$this->assertTrue(strpos($comment_permalink, '#comment-' . $comment1->id()), "The comment's title link contains the url fragment.");
$this->assertEqual($comment1->permalink()->toString(), $comment_permalink, "The comment's title has the correct link.");
diff --git a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php b/core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php
index 6caea17..a7fe6b5 100644
--- a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Component\Render\FormattableMarkup;
diff --git a/core/modules/comment/src/Tests/CommentTranslationUITest.php b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
index 4613d66..daac938 100644
--- a/core/modules/comment/src/Tests/CommentTranslationUITest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
@@ -1,10 +1,11 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
-use Drupal\content_translation\Tests\ContentTranslationUITestBase;
+use Drupal\comment\Tests\CommentTestTrait;
use Drupal\language\Entity\ConfigurableLanguage;
+use Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase;
/**
* Tests the Comment Translation UI.
diff --git a/core/modules/comment/src/Tests/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
index 343bb91..e4ff2ea 100644
--- a/core/modules/comment/src/Tests/CommentTypeTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Entity\CommentType;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
diff --git a/core/modules/comment/src/Tests/CommentUninstallTest.php b/core/modules/comment/tests/src/Functional/CommentUninstallTest.php
index 7873915..6e0c8a2 100644
--- a/core/modules/comment/src/Tests/CommentUninstallTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentUninstallTest.php
@@ -1,17 +1,18 @@
<?php
-namespace Drupal\comment\Tests;
+namespace Drupal\Tests\comment\Functional;
+use Drupal\comment\Tests\CommentTestTrait;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Core\Extension\ModuleUninstallValidatorException;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
/**
* Tests comment module uninstallation.
*
* @group comment
*/
-class CommentUninstallTest extends WebTestBase {
+class CommentUninstallTest extends BrowserTestBase {
use CommentTestTrait;
diff --git a/core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php b/core/modules/comment/tests/src/Functional/Views/ArgumentUserUIDTest.php
index d3526dc..ad08f4f 100644
--- a/core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/ArgumentUserUIDTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
use Drupal\comment\Entity\Comment;
use Drupal\user\Entity\User;
diff --git a/core/modules/comment/src/Tests/Views/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php
index c834bca..ee42dca 100644
--- a/core/modules/comment/src/Tests/Views/CommentAdminTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php
@@ -1,13 +1,13 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
use Drupal\block_content\Entity\BlockContent;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Component\Render\FormattableMarkup;
-use Drupal\comment\Tests\CommentTestBase as CommentWebTestBase;
+use Drupal\Tests\comment\Functional\CommentTestBase as CommentBrowserTestBase;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\user\RoleInterface;
@@ -18,7 +18,7 @@ use Drupal\views\Views;
*
* @group comment
*/
-class CommentAdminTest extends CommentWebTestBase {
+class CommentAdminTest extends CommentBrowserTestBase {
/**
* {@inheritdoc}
diff --git a/core/modules/comment/src/Tests/Views/CommentEditTest.php b/core/modules/comment/tests/src/Functional/Views/CommentEditTest.php
index 2a11ef9..fb5f736 100644
--- a/core/modules/comment/src/Tests/Views/CommentEditTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/CommentEditTest.php
@@ -1,15 +1,15 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
-use Drupal\comment\Tests\CommentTestBase as CommentWebTestBase;
+use Drupal\Tests\comment\Functional\CommentTestBase as CommentBrowserTestBase;
/**
* Tests comment edit functionality.
*
* @group comment
*/
-class CommentEditTest extends CommentWebTestBase {
+class CommentEditTest extends CommentBrowserTestBase {
/**
* {@inheritdoc}
@@ -25,7 +25,7 @@ class CommentEditTest extends CommentWebTestBase {
$node_comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), TRUE);
$this->drupalGet('admin/content/comment');
$this->assertText($this->adminUser->label());
- $this->drupalGet($node_comment->toUrl('edit-form')->toString());
+ $this->drupalGet($node_comment->toUrl('edit-form'));
$edit = [
'comment_body[0][value]' => $this->randomMachineName(),
];
diff --git a/core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php b/core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php
index 48f7d6d..dabacc3 100644
--- a/core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\comment\Entity\Comment;
@@ -31,8 +31,8 @@ class CommentFieldFilterTest extends CommentTestBase {
*/
public $commentTitles = [];
- public function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->drupalLogin($this->drupalCreateUser(['access comments']));
// Add two new languages.
diff --git a/core/modules/comment/src/Tests/Views/CommentFieldNameTest.php b/core/modules/comment/tests/src/Functional/Views/CommentFieldNameTest.php
index 870a4f4..a5e25be 100644
--- a/core/modules/comment/src/Tests/Views/CommentFieldNameTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/CommentFieldNameTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
use Drupal\comment\Entity\Comment;
use Drupal\Core\Render\RenderContext;
@@ -39,8 +39,8 @@ class CommentFieldNameTest extends CommentTestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->addDefaultCommentField('node', 'page', $this->fieldName);
$this->customComment = Comment::create([
'entity_id' => $this->nodeUserCommented->id(),
diff --git a/core/modules/comment/src/Tests/Views/CommentOperationsTest.php b/core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php
index 89dc364..4bef37e 100644
--- a/core/modules/comment/src/Tests/Views/CommentOperationsTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
/**
* Tests comment operations.
diff --git a/core/modules/comment/src/Tests/Views/CommentRestExportTest.php b/core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php
index ed7ce55..17e04b5 100644
--- a/core/modules/comment/src/Tests/Views/CommentRestExportTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
use Drupal\Component\Serialization\Json;
use Drupal\comment\Entity\Comment;
@@ -24,8 +24,8 @@ class CommentRestExportTest extends CommentTestBase {
*/
public static $modules = ['node', 'comment', 'comment_test_views', 'rest', 'hal'];
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
// Add another anonymous comment.
$comment = [
'uid' => 0,
@@ -51,7 +51,7 @@ class CommentRestExportTest extends CommentTestBase {
* Test comment row.
*/
public function testCommentRestExport() {
- $this->drupalGetWithFormat(sprintf('node/%d/comments', $this->nodeUserCommented->id()), 'hal_json');
+ $this->drupalGet(sprintf('node/%d/comments', $this->nodeUserCommented->id()), ['query' => ['_format' => 'hal_json']]);
$this->assertResponse(200);
$contents = Json::decode($this->getRawContent());
$this->assertEqual($contents[0]['subject'], 'How much wood would a woodchuck chuck');
diff --git a/core/modules/comment/src/Tests/Views/CommentRowTest.php b/core/modules/comment/tests/src/Functional/Views/CommentRowTest.php
index d73811e..7cf3ef3 100644
--- a/core/modules/comment/src/Tests/Views/CommentRowTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/CommentRowTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
/**
* Tests the comment row plugin.
diff --git a/core/modules/comment/tests/src/Functional/Views/CommentTestBase.php b/core/modules/comment/tests/src/Functional/Views/CommentTestBase.php
new file mode 100644
index 0000000..a9444a2
--- /dev/null
+++ b/core/modules/comment/tests/src/Functional/Views/CommentTestBase.php
@@ -0,0 +1,90 @@
+<?php
+
+namespace Drupal\Tests\comment\Functional\Views;
+
+use Drupal\comment\Tests\CommentTestTrait;
+use Drupal\Tests\views\Functional\ViewTestBase;
+use Drupal\views\Tests\ViewTestData;
+use Drupal\comment\Entity\Comment;
+
+/**
+ * Provides setup and helper methods for comment views tests.
+ */
+abstract class CommentTestBase extends ViewTestBase {
+
+ use CommentTestTrait;
+
+ /**
+ * Modules to install.
+ *
+ * @var array
+ */
+ public static $modules = ['node', 'comment', 'comment_test_views'];
+
+ /**
+ * A normal user with permission to post comments (without approval).
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $account;
+
+ /**
+ * A second normal user that will author a node for $account to comment on.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $account2;
+
+ /**
+ * Stores a node posted by the user created as $account.
+ *
+ * @var \Drupal\node\NodeInterface
+ */
+ protected $nodeUserPosted;
+
+ /**
+ * Stores a node posted by the user created as $account2.
+ *
+ * @var \Drupal\node\NodeInterface
+ */
+ protected $nodeUserCommented;
+
+ /**
+ * Stores a comment used by the tests.
+ *
+ * @var \Drupal\comment\Entity\Comment
+ */
+ protected $comment;
+
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
+
+ ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
+
+ // Add two users, create a node with the user1 as author and another node
+ // with user2 as author. For the second node add a comment from user1.
+ $this->account = $this->drupalCreateUser(['skip comment approval']);
+ $this->account2 = $this->drupalCreateUser();
+ $this->drupalLogin($this->account);
+
+ $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]);
+ $this->addDefaultCommentField('node', 'page');
+
+ $this->nodeUserPosted = $this->drupalCreateNode();
+ $this->nodeUserCommented = $this->drupalCreateNode(['uid' => $this->account2->id()]);
+
+ $comment = [
+ 'uid' => $this->loggedInUser->id(),
+ 'entity_id' => $this->nodeUserCommented->id(),
+ 'entity_type' => 'node',
+ 'field_name' => 'comment',
+ 'subject' => 'How much wood would a woodchuck chuck',
+ 'cid' => '',
+ 'pid' => '',
+ 'mail' => 'someone@example.com',
+ ];
+ $this->comment = Comment::create($comment);
+ $this->comment->save();
+ }
+
+}
diff --git a/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php b/core/modules/comment/tests/src/Functional/Views/DefaultViewRecentCommentsTest.php
index de8882e..5cb9680 100644
--- a/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/DefaultViewRecentCommentsTest.php
@@ -1,12 +1,12 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\views\Views;
-use Drupal\views\Tests\ViewTestBase;
+use Drupal\Tests\views\Functional\ViewTestBase;
/**
* Tests results for the Recent Comments view shipped with the module.
@@ -59,8 +59,8 @@ class DefaultViewRecentCommentsTest extends ViewTestBase {
*/
public $node;
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
// Create a new content type
$content_type = $this->drupalCreateContentType();
diff --git a/core/modules/comment/src/Tests/Views/FilterUserUIDTest.php b/core/modules/comment/tests/src/Functional/Views/FilterUserUIDTest.php
index 442a0e7..719c597 100644
--- a/core/modules/comment/src/Tests/Views/FilterUserUIDTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/FilterUserUIDTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
use Drupal\comment\Entity\Comment;
use Drupal\user\Entity\User;
diff --git a/core/modules/comment/src/Tests/Views/NodeCommentsTest.php b/core/modules/comment/tests/src/Functional/Views/NodeCommentsTest.php
index b0ee315..e2c5d15 100644
--- a/core/modules/comment/src/Tests/Views/NodeCommentsTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/NodeCommentsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
/**
* Tests comments on nodes.
diff --git a/core/modules/comment/src/Tests/Views/RowRssTest.php b/core/modules/comment/tests/src/Functional/Views/RowRssTest.php
index 343b797..7d61852 100644
--- a/core/modules/comment/src/Tests/Views/RowRssTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/RowRssTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
/**
* Tests the comment rss row plugin.
@@ -23,10 +23,12 @@ class RowRssTest extends CommentTestBase {
public function testRssRow() {
$this->drupalGet('test-comment-rss');
- $result = $this->xpath('//item');
+ // Because the response is XML we can't use the page which depends on an
+ // HTML tag being present.
+ $result = $this->getSession()->getDriver()->find('//item');
$this->assertEqual(count($result), 1, 'Just one comment was found in the rss output.');
- $this->assertEqual($result[0]->pubdate, gmdate('r', $this->comment->getCreatedTime()), 'The right pubDate appears in the rss output.');
+ $this->assertEqual($result[0]->find('xpath', '//pubDate')->getHtml(), gmdate('r', $this->comment->getCreatedTime()), 'The right pubDate appears in the rss output.');
}
}
diff --git a/core/modules/comment/src/Tests/Views/WizardTest.php b/core/modules/comment/tests/src/Functional/Views/WizardTest.php
index a7f14c8..62fada9 100644
--- a/core/modules/comment/src/Tests/Views/WizardTest.php
+++ b/core/modules/comment/tests/src/Functional/Views/WizardTest.php
@@ -1,10 +1,10 @@
<?php
-namespace Drupal\comment\Tests\Views;
+namespace Drupal\Tests\comment\Functional\Views;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\views\Views;
-use Drupal\views\Tests\Wizard\WizardTestBase;
+use Drupal\Tests\views\Functional\Wizard\WizardTestBase;
/**
* Tests the comment module integration into the wizard.
@@ -27,8 +27,8 @@ class WizardTest extends WizardTestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]);
// Add comment field to page node type.
$this->addDefaultCommentField('node', 'page');
@@ -63,7 +63,7 @@ class WizardTest extends WizardTestBase {
foreach ($fields as $field) {
$items = $this->getAllOptions($field);
foreach ($items as $item) {
- $options[] = $item->attributes()->value;
+ $options[] = $item->getValue();
}
}
$expected_options = ['entity:comment', 'fields'];