public function LingotekConfigImportTest::testConfigImportUpdates in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8.2 src/Tests/Kernel/LingotekConfigImportTest.php \Drupal\lingotek\Tests\Kernel\LingotekConfigImportTest::testConfigImportUpdates()
- 3.0.x src/Tests/Kernel/LingotekConfigImportTest.php \Drupal\lingotek\Tests\Kernel\LingotekConfigImportTest::testConfigImportUpdates()
- 3.1.x src/Tests/Kernel/LingotekConfigImportTest.php \Drupal\lingotek\Tests\Kernel\LingotekConfigImportTest::testConfigImportUpdates()
- 3.2.x src/Tests/Kernel/LingotekConfigImportTest.php \Drupal\lingotek\Tests\Kernel\LingotekConfigImportTest::testConfigImportUpdates()
- 3.3.x src/Tests/Kernel/LingotekConfigImportTest.php \Drupal\lingotek\Tests\Kernel\LingotekConfigImportTest::testConfigImportUpdates()
- 3.4.x src/Tests/Kernel/LingotekConfigImportTest.php \Drupal\lingotek\Tests\Kernel\LingotekConfigImportTest::testConfigImportUpdates()
- 3.5.x src/Tests/Kernel/LingotekConfigImportTest.php \Drupal\lingotek\Tests\Kernel\LingotekConfigImportTest::testConfigImportUpdates()
- 3.6.x src/Tests/Kernel/LingotekConfigImportTest.php \Drupal\lingotek\Tests\Kernel\LingotekConfigImportTest::testConfigImportUpdates()
- 3.7.x src/Tests/Kernel/LingotekConfigImportTest.php \Drupal\lingotek\Tests\Kernel\LingotekConfigImportTest::testConfigImportUpdates()
- 3.8.x src/Tests/Kernel/LingotekConfigImportTest.php \Drupal\lingotek\Tests\Kernel\LingotekConfigImportTest::testConfigImportUpdates()
Tests config import updates.
File
- src/
Tests/ Kernel/ LingotekConfigImportTest.php, line 41
Class
- LingotekConfigImportTest
- Tests content translation updates performed during config import.
Namespace
Drupal\lingotek\Tests\KernelCode
public function testConfigImportUpdates() {
// Create a content entity and some config that depends on it.
$content_entity = EntityTestMul::create([]);
$content_entity
->save();
$storage = $this->container
->get('entity_type.manager')
->getStorage('config_test');
// Test dependencies between modules.
$entity1 = $storage
->create([
'id' => 'entity1',
'dependencies' => [
'enforced' => [
'content' => [
$content_entity
->getConfigDependencyName(),
],
],
],
]);
$entity1
->save();
// Copy all configuration to staging.
$this
->copyConfig($this->container
->get('config.storage'), $this->container
->get('config.storage.sync'));
// Set up the lingotek configuration in staging.
$entity_type_id = 'entity_test_mul';
$config_name = 'lingotek.settings';
$config_id = $entity_type_id . '.' . $entity_type_id;
$storage = $this->container
->get('config.storage');
$sync = $this->container
->get('config.storage.sync');
// Create new config entity for content settings.
\Drupal::service('content_translation.manager')
->setEnabled($entity_type_id, $entity_type_id, TRUE);
// Verify the configuration to create does not exist yet.
$this
->assertIdentical($storage
->exists($config_name), FALSE, $config_name . ' not found.');
// Create new config entity for content language translation.
$data = [
'uuid' => 'a019d89b-c4d9-4ed4-b859-894e4e2e93cf',
'langcode' => 'en',
'status' => TRUE,
'dependencies' => [
'module' => [
'content_translation',
],
],
'id' => $config_id,
'target_entity_type_id' => 'entity_test_mul',
'target_bundle' => 'entity_test_mul',
'default_langcode' => 'site_default',
'language_alterable' => FALSE,
'third_party_settings' => [
'content_translation' => [
'enabled' => TRUE,
],
],
];
$sync
->write('language.content_settings.' . $config_id, $data);
// Create new config for lingotek settings.
$data = [
'translate' => [
'entity' => [
$entity_type_id => [
$entity_type_id => [
'enabled' => TRUE,
'field' => [
'name' => TRUE,
'field_test_text' => TRUE,
],
'profile' => 'automatic',
],
],
],
],
];
$sync
->write($config_name, $data);
$this
->assertIdentical($sync
->exists($config_name), TRUE, $config_name . ' found.');
// Import.
$this
->configImporter()
->import();
// Verify the values appeared.
$config = $this
->config($config_name);
$this
->assertIdentical($config
->get('translate.entity.entity_test_mul.entity_test_mul.field.field_test_text'), TRUE);
/** @var \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_config */
$lingotek_config = \Drupal::service('lingotek.configuration');
$this
->assertIdentical($lingotek_config
->isEnabled($entity_type_id), TRUE);
}