namespace Drupal\Tests\comment\Kernel\Views;
-use Drupal\comment\CommentInterface;
use Drupal\comment\CommentManagerInterface;
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\Core\Url;
*/
class CommentLinksTest extends CommentViewsKernelTestBase {
+ /**
+ * Modules to enable.
+ *
+ * @var array
+ */
+ public static $modules = ['entity_test'];
+
/**
* Views used by this test.
*
*/
public static $testViews = ['test_comment'];
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
+
+ $this->installEntitySchema('entity_test');
+ }
+
/**
* Test the comment approve link.
*/
public function testLinkApprove() {
+ $host = EntityTest::create(['name' => $this->randomString()]);
+ $host->save();
// Create an unapproved comment.
$comment = $this->commentStorage->create([
'uid' => $this->adminUser->id(),
'entity_type' => 'entity_test',
+ 'entity_id' => $host->id(),
'comment_type' => 'entity_test',
'status' => 0,
]);
$this->assertEqual(\Drupal::l('Approve', $url), (string) $approve_comment, 'Found a comment approve link for an unapproved comment.');
// Approve the comment.
- $comment->setPublished(CommentInterface::PUBLISHED);
+ $comment->setPublished();
$comment->save();
$view = Views::getView('test_comment');
$view->preview();
// anonymous user.
$account_switcher->switchTo(new AnonymousUserSession());
// Set the comment as unpublished again.
- $comment->setPublished(CommentInterface::NOT_PUBLISHED);
+ $comment->setUnpublished();
$comment->save();
$view = Views::getView('test_comment');
* Test the comment reply link.
*/
public function testLinkReply() {
- $this->enableModules(['field', 'entity_test']);
- $this->installEntitySchema('entity_test');
+ $this->enableModules(['field']);
$this->installSchema('comment', ['comment_entity_statistics']);
$this->installConfig(['field']);
$this->assertFalse((string) $replyto_comment, "I can't reply to an unapproved comment.");
// Approve the comment.
- $comment->setPublished(CommentInterface::PUBLISHED);
+ $comment->setPublished();
$comment->save();
$view = Views::getView('test_comment');
$view->preview();