You are here

public function CommentUpdateTest::testPublishedEntityKey in Drupal 8

Tests that the comment entity type has a 'published' entity key.

See also

comment_update_8301()

File

core/modules/comment/tests/src/Functional/Update/CommentUpdateTest.php, line 59

Class

CommentUpdateTest
Tests that comment settings are properly updated during database updates.

Namespace

Drupal\Tests\comment\Functional\Update

Code

public function testPublishedEntityKey() {

  // Check that the 'published' entity key does not exist prior to the update.
  $entity_type = \Drupal::entityDefinitionUpdateManager()
    ->getEntityType('comment');
  $this
    ->assertFalse($entity_type
    ->getKey('published'));

  // Run updates.
  $this
    ->runUpdates();

  // Check that the entity key exists and it has the correct value.
  $entity_type = \Drupal::entityDefinitionUpdateManager()
    ->getEntityType('comment');
  $this
    ->assertEqual('status', $entity_type
    ->getKey('published'));

  // Check that the {comment_field_data} table status index has been created.
  $this
    ->assertTrue(\Drupal::database()
    ->schema()
    ->indexExists('comment_field_data', 'comment__status_comment_type'));
}