You are here

public function ContentTranslationUpdateTest::testContentTranslationUpdate8400 in Drupal 8

Tests that initial values for metadata fields are populated correctly.

File

core/modules/content_translation/tests/src/Functional/Update/ContentTranslationUpdateTest.php, line 63

Class

ContentTranslationUpdateTest
Tests the upgrade path for the Content Translation module.

Namespace

Drupal\Tests\content_translation\Functional\Update

Code

public function testContentTranslationUpdate8400() {
  $this
    ->updateEntityTypeToTranslatable();

  // The test database dump contains NULL values for
  // 'content_translation_source', 'content_translation_outdated' and
  // 'content_translation_status' for the first 50 test entities.
  // @see _entity_test_update_create_test_entities()
  $first_entity_record = $this->database
    ->select('entity_test_update_data', 'etud')
    ->fields('etud')
    ->condition('etud.id', 1)
    ->execute()
    ->fetchAllAssoc('id');
  $this
    ->assertNull($first_entity_record[1]->content_translation_source);
  $this
    ->assertNull($first_entity_record[1]->content_translation_outdated);
  $this
    ->assertNull($first_entity_record[1]->content_translation_status);
  $this
    ->runUpdates();

  // After running the updates, all those fields should be populated with
  // their default values.
  $first_entity_record = $this->database
    ->select('entity_test_update_data', 'etud')
    ->fields('etud')
    ->condition('etud.id', 1)
    ->execute()
    ->fetchAllAssoc('id');
  $this
    ->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $first_entity_record[1]->content_translation_source);
  $this
    ->assertEqual(0, $first_entity_record[1]->content_translation_outdated);
  $this
    ->assertEqual(1, $first_entity_record[1]->content_translation_status);
}