3 namespace Drupal\content_translation\Tests;
5 use Drupal\simpletest\WebTestBase;
8 * Test enabling content translation module.
10 * @group content_translation
12 class ContentTranslationEnableTest extends WebTestBase {
17 public static $modules = ['entity_test', 'menu_link_content', 'node'];
20 * Tests that entity schemas are up-to-date after enabling translation.
22 public function testEnable() {
23 $this->drupalLogin($this->rootUser);
24 // Enable modules and make sure the related config entity type definitions
27 'modules[content_translation][enable]' => TRUE,
28 'modules[language][enable]' => TRUE,
30 $this->drupalPostForm('admin/modules', $edit, t('Install'));
32 // Status messages are shown.
33 $this->assertText(t('This site has only a single language enabled. Add at least one more language in order to translate content.'));
34 $this->assertText(t('Enable translation for content types, taxonomy vocabularies, accounts, or any other element you wish to translate.'));
36 // No pending updates should be available.
37 $this->drupalGet('admin/reports/status');
38 $requirement_value = $this->cssSelect("details.system-status-report__entry summary:contains('Entity/field definitions') + div");
39 $this->assertEqual(t('Up to date'), trim((string) $requirement_value[0]));
41 $this->drupalGet('admin/config/regional/content-language');
42 // The node entity type should not be an option because it has no bundles.
43 $this->assertNoRaw('entity_types[node]');
44 // Enable content translation on entity types that have will have a
45 // content_translation_uid.
47 'entity_types[menu_link_content]' => TRUE,
48 'settings[menu_link_content][menu_link_content][translatable]' => TRUE,
49 'entity_types[entity_test_mul]' => TRUE,
50 'settings[entity_test_mul][entity_test_mul][translatable]' => TRUE,
52 $this->drupalPostForm(NULL, $edit, t('Save configuration'));
54 // No pending updates should be available.
55 $this->drupalGet('admin/reports/status');
56 $requirement_value = $this->cssSelect("details.system-status-report__entry summary:contains('Entity/field definitions') + div");
57 $this->assertEqual(t('Up to date'), trim((string) $requirement_value[0]));
59 // Create a node type and check the content translation settings are now
60 // available for nodes.
63 'title_label' => 'title for foo',
66 $this->drupalPostForm('admin/structure/types/add', $edit, t('Save content type'));
67 $this->drupalGet('admin/config/regional/content-language');
68 $this->assertRaw('entity_types[node]');