3 namespace Drupal\Tests\content_translation\Functional\Update;
5 use Drupal\Core\Language\LanguageInterface;
6 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
7 use Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait;
10 * Tests the upgrade path for the Content Translation module.
15 class ContentTranslationUpdateTest extends UpdatePathTestBase {
17 use EntityDefinitionTestTrait;
20 * The database connection used.
22 * @var \Drupal\Core\Database\Connection
27 * The entity definition update manager.
29 * @var \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface
31 protected $entityDefinitionUpdateManager;
34 * The entity manager service.
36 * @var \Drupal\Core\Entity\EntityManagerInterface
38 protected $entityManager;
43 * @var \Drupal\Core\State\StateInterface
50 protected function setUp() {
53 $this->database = \Drupal::database();
54 $this->entityDefinitionUpdateManager = \Drupal::entityDefinitionUpdateManager();
55 $this->entityManager = \Drupal::entityManager();
56 $this->state = \Drupal::state();
62 public function setDatabaseDumpFiles() {
63 $this->databaseDumpFiles = [
64 __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.0.0-rc1-filled.standard.entity_test_update_mul.php.gz',
69 * Tests that initial values for metadata fields are populated correctly.
71 public function testContentTranslationUpdate8400() {
72 $this->updateEntityTypeToTranslatable();
74 // The test database dump contains NULL values for
75 // 'content_translation_source', 'content_translation_outdated' and
76 // 'content_translation_status' for the first 50 test entities.
77 // @see _entity_test_update_create_test_entities()
78 $first_entity_record = $this->database->select('entity_test_update_data', 'etud')
80 ->condition('etud.id', 1)
82 ->fetchAllAssoc('id');
83 $this->assertNull($first_entity_record[1]->content_translation_source);
84 $this->assertNull($first_entity_record[1]->content_translation_outdated);
85 $this->assertNull($first_entity_record[1]->content_translation_status);
89 // After running the updates, all those fields should be populated with
90 // their default values.
91 $first_entity_record = $this->database->select('entity_test_update_data', 'etud')
93 ->condition('etud.id', 1)
95 ->fetchAllAssoc('id');
96 $this->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $first_entity_record[1]->content_translation_source);
97 $this->assertEqual(0, $first_entity_record[1]->content_translation_outdated);
98 $this->assertEqual(1, $first_entity_record[1]->content_translation_status);