9a0122334ee1d849526c6b28f3b8ebc632efe030
[yaffs-website] / vendor / drush / drush / tests / PmEnLocaleImportTest.php
1 <?php
2
3 namespace Unish;
4
5 use Drupal\Core\Language\Language;
6 use Drupal\language\Entity\ConfigurableLanguage;
7 use Webmozart\PathUtil\Path;
8
9 /**
10  *  @group slow
11  *  @group pm
12  */
13 class PmEnLocaleImportCase extends CommandUnishTestCase
14 {
15
16     public function testBatchImportTranslations()
17     {
18         $sites = $this->setUpDrupal(1, true);
19         $uri = key($sites);
20         $root = $this->webroot();
21         $options = array(
22             'root' => $root,
23             'uri' => $uri,
24         );
25
26         $this->drush('pm-enable', ['language', 'locale', 'dblog'], $options);
27         $this->drush('config-set', ['locale.settings', 'translation.import_enabled', true], $options);
28
29         // Setup the interface translation system and prepare a source translation file.
30         // The test uses a local po file as translation source. This po file will be
31         // imported from the translations directory when a module is enabled.
32         $this->drush('config-set', ['locale.settings', 'translation.use_source', 'locale'], $options);
33         $this->drush('config-set', ['locale.settings', 'translation.default_filename', '%project.%language.po'], $options);
34         $this->drush('config-set', ['locale.settings', 'translation.path', '../translations'], $options);
35         $source = Path::join(__DIR__, '/resources/devel.nl.po');
36         $translationDir = Path::join($root, '../translations');
37         $this->mkdir($translationDir);
38         copy($source, $translationDir . '/devel.nl.po');
39
40         $this->drush('php-eval', ['\Drupal\language\Entity\ConfigurableLanguage::create([
41             "id" => "nl",
42             "label" => "Dutch",
43         ])->save()']);
44
45         $this->drush('pm-enable', ['devel'], $options);
46         $this->drush('watchdog-show', [], $options);
47         $this->assertContains('Translations imported:', $this->getSimplifiedOutput());
48
49         // Clean up the mess this test creates.
50         unlink($translationDir . '/devel.nl.po');
51         rmdir($translationDir);
52     }
53 }