More updates to stop using dev or alpha or beta versions.
[yaffs-website] / web / core / modules / config_translation / src / Tests / ConfigTranslationInstallTest.php
1 <?php
2
3 namespace Drupal\config_translation\Tests;
4
5 use Drupal\simpletest\InstallerTestBase;
6
7 /**
8  * Installs the config translation module on a site installed in non english.
9  *
10  * @group config_translation
11  */
12 class ConfigTranslationInstallTest extends InstallerTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   protected $langcode = 'eo';
18
19   /**
20    * {@inheritdoc}
21    */
22   protected $profile = 'standard';
23
24   /**
25    * {@inheritdoc}
26    */
27   protected function setUpLanguage() {
28     // Place custom local translations in the translations directory.
29     mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
30     file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.eo.po', $this->getPo('eo'));
31
32     parent::setUpLanguage();
33
34     $this->translations['Save and continue'] = 'Save and continue eo';
35   }
36
37   /**
38    * Returns the string for the test .po file.
39    *
40    * @param string $langcode
41    *   The language code.
42    * @return string
43    *   Contents for the test .po file.
44    */
45   protected function getPo($langcode) {
46     return <<<ENDPO
47 msgid ""
48 msgstr ""
49
50 msgid "Save and continue"
51 msgstr "Save and continue $langcode"
52
53 msgid "Anonymous"
54 msgstr "Anonymous $langcode"
55
56 msgid "Language"
57 msgstr "Language $langcode"
58 ENDPO;
59   }
60
61   public function testConfigTranslation() {
62     $this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'en'], t('Add custom language'));
63     $this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'fr'], t('Add custom language'));
64
65     $edit = [
66       'modules[config_translation][enable]' => TRUE,
67     ];
68     $this->drupalPostForm('admin/modules', $edit, t('Install'));
69
70     $this->drupalGet('/admin/structure/types/manage/article/fields');
71     $this->assertResponse(200);
72   }
73
74 }