3 namespace Drupal\comment\Tests\Update;
5 use Drupal\system\Tests\Update\UpdatePathTestBase;
8 * Tests that comment settings are properly updated during database updates.
12 class CommentUpdateTest extends UpdatePathTestBase {
17 protected function setDatabaseDumpFiles() {
18 $this->databaseDumpFiles = [
19 __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz',
24 * Tests comment_update_8200().
26 * @see comment_update_8200()
28 public function testCommentUpdate8101() {
29 // Load the 'node.article.default' entity view display config, and check
30 // that component 'comment' does not contain the 'view_mode' setting.
31 $config = $this->config('core.entity_view_display.node.article.default');
32 $this->assertNull($config->get('content.comment.settings.view_mode'));
34 // Load the 'node.forum.default' entity view display config, and check that
35 // component 'comment_forum' does not contain the 'view_mode' setting.
36 $config = $this->config('core.entity_view_display.node.forum.default');
37 $this->assertNull($config->get('content.comment_forum.settings.view_mode'));
42 // Check that 'node.article.default' entity view display setting 'view_mode'
43 // has the value 'default'.
44 $config = $this->config('core.entity_view_display.node.article.default');
45 $this->assertIdentical($config->get('content.comment.settings.view_mode'), 'default');
47 // Check that 'node.forum.default' entity view display setting 'view_mode'
48 // has the value 'default'.
49 $config = $this->config('core.entity_view_display.node.forum.default');
50 $this->assertIdentical($config->get('content.comment_forum.settings.view_mode'), 'default');
54 * Tests that the comment entity type has a 'published' entity key.
56 * @see comment_update_8301()
58 public function testPublishedEntityKey() {
59 // Check that the 'published' entity key does not exist prior to the update.
60 $entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('comment');
61 $this->assertFalse($entity_type->getKey('published'));
66 // Check that the entity key exists and it has the correct value.
67 $entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('comment');
68 $this->assertEqual('status', $entity_type->getKey('published'));
70 // Check that the {comment_field_data} table status index has been created.
71 $this->assertTrue(\Drupal::database()->schema()->indexExists('comment_field_data', 'comment__status_comment_type'));