X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcomment%2Ftests%2Fsrc%2FKernel%2FViews%2FCommentLinksTest.php;h=acd2cf6e72c4a61bec4d6636affaa34671bf0238;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=ffb91b0688747a1f4bb24162c23cdad8d9d50e29;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/comment/tests/src/Kernel/Views/CommentLinksTest.php b/web/core/modules/comment/tests/src/Kernel/Views/CommentLinksTest.php index ffb91b068..acd2cf6e7 100644 --- a/web/core/modules/comment/tests/src/Kernel/Views/CommentLinksTest.php +++ b/web/core/modules/comment/tests/src/Kernel/Views/CommentLinksTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\comment\Kernel\Views; -use Drupal\comment\CommentInterface; use Drupal\comment\CommentManagerInterface; use Drupal\Core\Session\AnonymousUserSession; use Drupal\Core\Url; @@ -18,6 +17,13 @@ use Drupal\views\Views; */ class CommentLinksTest extends CommentViewsKernelTestBase { + /** + * Modules to enable. + * + * @var array + */ + public static $modules = ['entity_test']; + /** * Views used by this test. * @@ -25,15 +31,27 @@ class CommentLinksTest extends CommentViewsKernelTestBase { */ 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, ]); @@ -65,7 +83,7 @@ class CommentLinksTest extends CommentViewsKernelTestBase { $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(); @@ -78,7 +96,7 @@ class CommentLinksTest extends CommentViewsKernelTestBase { // 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'); @@ -91,8 +109,7 @@ class CommentLinksTest extends CommentViewsKernelTestBase { * 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']); @@ -150,7 +167,7 @@ class CommentLinksTest extends CommentViewsKernelTestBase { $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();