Backup of db before drupal security update
[yaffs-website] / web / core / modules / content_translation / src / Tests / ContentTranslationEnableTest.php
1 <?php
2
3 namespace Drupal\content_translation\Tests;
4
5 use Drupal\simpletest\WebTestBase;
6
7 /**
8  * Test enabling content translation module.
9  *
10  * @group content_translation
11  */
12 class ContentTranslationEnableTest extends WebTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['entity_test', 'menu_link_content', 'node'];
18
19   /**
20    * Tests that entity schemas are up-to-date after enabling translation.
21    */
22   public function testEnable() {
23     $this->drupalLogin($this->rootUser);
24     // Enable modules and make sure the related config entity type definitions
25     // are installed.
26     $edit = [
27       'modules[content_translation][enable]' => TRUE,
28       'modules[language][enable]' => TRUE,
29     ];
30     $this->drupalPostForm('admin/modules', $edit, t('Install'));
31
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.'));
35
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]));
40
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.
46     $edit = [
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,
51     ];
52     $this->drupalPostForm(NULL, $edit, t('Save configuration'));
53
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]));
58
59     // Create a node type and check the content translation settings are now
60     // available for nodes.
61     $edit = [
62       'name' => 'foo',
63       'title_label' => 'title for foo',
64       'type' => 'foo',
65     ];
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]');
69   }
70
71 }