3 namespace Drupal\Tests\content_translation\Kernel;
5 use Drupal\Core\Config\ConfigImporter;
6 use Drupal\Core\Config\StorageComparer;
7 use Drupal\KernelTests\KernelTestBase;
10 * Tests content translation updates performed during config import.
12 * @group content_translation
14 class ContentTranslationConfigImportTest extends KernelTestBase {
17 * Config Importer object used for testing.
19 * @var \Drupal\Core\Config\ConfigImporter
21 protected $configImporter;
28 public static $modules = ['system', 'user', 'entity_test', 'language', 'content_translation'];
33 protected function setUp() {
36 $this->installEntitySchema('entity_test_mul');
37 $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
39 // Set up the ConfigImporter object for testing.
40 $storage_comparer = new StorageComparer(
41 $this->container->get('config.storage.sync'),
42 $this->container->get('config.storage'),
43 $this->container->get('config.manager')
45 $this->configImporter = new ConfigImporter(
46 $storage_comparer->createChangelist(),
47 $this->container->get('event_dispatcher'),
48 $this->container->get('config.manager'),
49 $this->container->get('lock'),
50 $this->container->get('config.typed'),
51 $this->container->get('module_handler'),
52 $this->container->get('module_installer'),
53 $this->container->get('theme_handler'),
54 $this->container->get('string_translation')
59 * Tests config import updates.
61 public function testConfigImportUpdates() {
62 $entity_type_id = 'entity_test_mul';
63 $config_id = $entity_type_id . '.' . $entity_type_id;
64 $config_name = 'language.content_settings.' . $config_id;
65 $storage = $this->container->get('config.storage');
66 $sync = $this->container->get('config.storage.sync');
68 // Verify the configuration to create does not exist yet.
69 $this->assertIdentical($storage->exists($config_name), FALSE, $config_name . ' not found.');
71 // Create new config entity.
73 'uuid' => 'a019d89b-c4d9-4ed4-b859-894e4e2e93cf',
77 'module' => ['content_translation']
80 'target_entity_type_id' => 'entity_test_mul',
81 'target_bundle' => 'entity_test_mul',
82 'default_langcode' => 'site_default',
83 'language_alterable' => FALSE,
84 'third_party_settings' => [
85 'content_translation' => ['enabled' => TRUE],
88 $sync->write($config_name, $data);
89 $this->assertIdentical($sync->exists($config_name), TRUE, $config_name . ' found.');
92 $this->configImporter->reset()->import();
94 // Verify the values appeared.
95 $config = $this->config($config_name);
96 $this->assertIdentical($config->get('id'), $config_id);
98 // Verify that updates were performed.
99 $entity_type = $this->container->get('entity.manager')->getDefinition($entity_type_id);
100 $table = $entity_type->getDataTable();
101 $db_schema = $this->container->get('database')->schema();
102 $result = $db_schema->fieldExists($table, 'content_translation_source') && $db_schema->fieldExists($table, 'content_translation_outdated');
103 $this->assertTrue($result, 'Content translation updates were successfully performed during config import.');