forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LanguageAddTest.php
67 lines (55 loc) · 2.66 KB
/
LanguageAddTest.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace Unish;
use Drupal\Core\Language\Language;
use Drupal\language\Entity\ConfigurableLanguage;
use Webmozart\PathUtil\Path;
/**
* @group slow
* @group pm
*/
class LanguageAddTest extends CommandUnishTestCase
{
protected function setup(): void
{
parent::setUp();
if (empty($this->getSites())) {
$this->setUpDrupal(1, true);
$this->drush('pm-install', ['language']);
}
}
public function testLanguageInfoAdd()
{
$this->drush('language-info', []);
$this->assertStringContainsString('English (en)', $this->getSimplifiedOutput());
$this->drush('language-add', ['nl,fr'], ['skip-translations' => null]);
$this->drush('language-info', []);
$this->assertStringContainsString('Dutch (nl)', $this->getSimplifiedOutput());
$this->assertStringContainsString('French (fr)', $this->getSimplifiedOutput());
}
public function testLanguageAddWithTranslations()
{
$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->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($this->webroot(), '../translations');
$this->mkdir($translationDir);
copy($source, Path::join($translationDir, 'drush_empty_module.nl.po'));
$this->drush('pm-install', ['drush_empty_module']);
$this->drush('language-add', ['nl']);
$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);
}
}