01249498b6344166749141028f8a5d2cdbc0ade5
[yaffs-website] / web / core / modules / comment / tests / src / Functional / Update / CommentAdminViewUpdateTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6
7 /**
8  * Tests that comment admin view is enabled after update.
9  *
10  * @see comment_post_update_enable_comment_admin_view()
11  *
12  * @group Update
13  * @group legacy
14  */
15 class CommentAdminViewUpdateTest extends UpdatePathTestBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   protected static $modules = ['comment', 'views'];
21
22   /**
23    * {@inheritdoc}
24    */
25   public function setDatabaseDumpFiles() {
26     $this->databaseDumpFiles = [
27       __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
28     ];
29   }
30
31   /**
32    * Tests that comment admin view is enabled after update.
33    */
34   public function testCommentAdminPostUpdateHook() {
35     $this->runUpdates();
36     // Ensure we can load the view from the storage after the update and it's
37     // enabled.
38     $entity_type_manager = \Drupal::entityTypeManager();
39     /** @var \Drupal\views\ViewEntityInterface $comment_admin_view */
40     $comment_admin_view = $entity_type_manager->getStorage('view')->load('comment');
41     $this->assertNotNull($comment_admin_view, 'Comment admin view exist in storage.');
42     $this->assertTrue($comment_admin_view->enable(), 'Comment admin view is enabled.');
43     $comment_delete_action = $entity_type_manager->getStorage('action')->load('comment_delete_action');
44     $this->assertNotNull($comment_delete_action, 'Comment delete action imported');
45     // Verify comment admin page is working after updates.
46     $account = $this->drupalCreateUser(['administer comments']);
47     $this->drupalLogin($account);
48     $this->drupalGet('admin/content/comment');
49     $this->assertText(t('No comments available.'));
50   }
51
52 }