d68b1e540cad94ae468abb4d5cbd78bd536f3d74
[yaffs-website] / web / core / modules / comment / tests / src / Functional / Update / CommentUpdateTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6
7 /**
8  * Tests that comment settings are properly updated during database updates.
9  *
10  * @group comment
11  * @group legacy
12  */
13 class CommentUpdateTest extends UpdatePathTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function setDatabaseDumpFiles() {
19     $this->databaseDumpFiles = [
20       __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz',
21     ];
22   }
23
24   /**
25    * Tests comment_update_8200().
26    *
27    * @see comment_update_8200()
28    */
29   public function testCommentUpdate8101() {
30     // Load the 'node.article.default' entity view display config, and check
31     // that component 'comment' does not contain the 'view_mode' setting.
32     $config = $this->config('core.entity_view_display.node.article.default');
33     $this->assertNull($config->get('content.comment.settings.view_mode'));
34
35     // Load the 'node.forum.default' entity view display config, and check that
36     // component 'comment_forum' does not contain the 'view_mode' setting.
37     $config = $this->config('core.entity_view_display.node.forum.default');
38     $this->assertNull($config->get('content.comment_forum.settings.view_mode'));
39
40     // Run updates.
41     $this->runUpdates();
42
43     // Check that 'node.article.default' entity view display setting 'view_mode'
44     // has the value 'default'.
45     $config = $this->config('core.entity_view_display.node.article.default');
46     $this->assertIdentical($config->get('content.comment.settings.view_mode'), 'default');
47
48     // Check that 'node.forum.default' entity view display setting 'view_mode'
49     // has the value 'default'.
50     $config = $this->config('core.entity_view_display.node.forum.default');
51     $this->assertIdentical($config->get('content.comment_forum.settings.view_mode'), 'default');
52   }
53
54   /**
55    * Tests that the comment entity type has a 'published' entity key.
56    *
57    * @see comment_update_8301()
58    */
59   public function testPublishedEntityKey() {
60     // Check that the 'published' entity key does not exist prior to the update.
61     $entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('comment');
62     $this->assertFalse($entity_type->getKey('published'));
63
64     // Run updates.
65     $this->runUpdates();
66
67     // Check that the entity key exists and it has the correct value.
68     $entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('comment');
69     $this->assertEqual('status', $entity_type->getKey('published'));
70
71     // Check that the {comment_field_data} table status index has been created.
72     $this->assertTrue(\Drupal::database()->schema()->indexExists('comment_field_data', 'comment__status_comment_type'));
73   }
74
75 }