forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PmEnLocaleImportTest.php
50 lines (41 loc) · 2.04 KB
/
PmEnLocaleImportTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Unish;
use Drupal\Core\Language\Language;
use Drupal\language\Entity\ConfigurableLanguage;
use Webmozart\PathUtil\Path;
/**
* @group locale
* @group slow
* @group pm
*/
class PmEnLocaleImportTest extends CommandUnishTestCase
{
public function testBatchImportTranslations()
{
$info_yml = Path::join($this->webroot(), 'modules/unish/drush_empty_module/drush_empty_module.info.yml');
if (strpos(file_get_contents($info_yml), 'project:') === false || $this->isWindows()) {
$this->markTestSkipped('Devel dev snapshot detected. Incompatible with translation import.');
}
$this->setUpDrupal(1, true);
$root = $this->webroot();
$this->drush('pm-install', ['language', 'locale', 'dblog']);
$this->drush('config-set', ['locale.settings', 'translation.import_enabled', true]);
// Setup the interface translation system and prepare a source translation file.
// The test uses a local po file as translation source. This po file will be
// imported from the translations directory when a module is enabled.
$this->drush('config-set', ['locale.settings', 'translation.use_source', 'locale']);
$this->drush('config-set', ['locale.settings', 'translation.default_filename', '%project.%language.po']);
$this->drush('config-set', ['locale.settings', 'translation.path', '../translations']);
$source = Path::join(__DIR__, 'resources/drush_empty_module.nl.po');
$translationDir = Path::join($root, '../translations');
$this->mkdir($translationDir);
copy($source, Path::join($translationDir, 'drush_empty_module.nl.po'));
$this->drush('language-add', ['nl']);
$this->drush('pm-install', ['drush_empty_module']);
$this->drush('watchdog-show');
$this->assertStringContainsString('Translations imported:', $this->getSimplifiedOutput());
// Clean up the mess this test creates.
unlink(Path::join($translationDir, 'drush_empty_module.nl.po'));
rmdir($translationDir);
}
}