3 namespace Drupal\Tests\content_translation\Functional\Update;
5 use Drupal\Core\Language\LanguageInterface;
6 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
7 use Drupal\system\Tests\Entity\EntityDefinitionTestTrait;
10 * Tests the upgrade path for the Content Translation module.
14 class ContentTranslationUpdateTest extends UpdatePathTestBase {
16 use EntityDefinitionTestTrait;
19 * The database connection used.
21 * @var \Drupal\Core\Database\Connection
26 * The entity definition update manager.
28 * @var \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface
30 protected $entityDefinitionUpdateManager;
33 * The entity manager service.
35 * @var \Drupal\Core\Entity\EntityManagerInterface
37 protected $entityManager;
42 * @var \Drupal\Core\State\StateInterface
49 protected function setUp() {
52 $this->database = \Drupal::database();
53 $this->entityDefinitionUpdateManager = \Drupal::entityDefinitionUpdateManager();
54 $this->entityManager = \Drupal::entityManager();
55 $this->state = \Drupal::state();
61 public function setDatabaseDumpFiles() {
62 $this->databaseDumpFiles = [
63 __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.0.0-rc1-filled.standard.entity_test_update_mul.php.gz',
68 * Tests that initial values for metadata fields are populated correctly.
70 public function testContentTranslationUpdate8400() {
71 $this->updateEntityTypeToTranslatable();
73 // The test database dump contains NULL values for
74 // 'content_translation_source', 'content_translation_outdated' and
75 // 'content_translation_status' for the first 50 test entities.
76 // @see _entity_test_update_create_test_entities()
77 $first_entity_record = $this->database->select('entity_test_update_data', 'etud')
79 ->condition('etud.id', 1)
81 ->fetchAllAssoc('id');
82 $this->assertNull($first_entity_record[1]->content_translation_source);
83 $this->assertNull($first_entity_record[1]->content_translation_outdated);
84 $this->assertNull($first_entity_record[1]->content_translation_status);
88 // After running the updates, all those fields should be populated with
89 // their default values.
90 $first_entity_record = $this->database->select('entity_test_update_data', 'etud')
92 ->condition('etud.id', 1)
94 ->fetchAllAssoc('id');
95 $this->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $first_entity_record[1]->content_translation_source);
96 $this->assertEqual(0, $first_entity_record[1]->content_translation_outdated);
97 $this->assertEqual(1, $first_entity_record[1]->content_translation_status);