Mercurial > hg > isophonics-drupal-site
comparison core/modules/locale/tests/src/Functional/LocaleTranslationDownloadTest.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\locale\Functional; | |
4 | |
5 use Drupal\Core\StreamWrapper\PublicStream; | |
6 use Drupal\language\Entity\ConfigurableLanguage; | |
7 use org\bovigo\vfs\vfsStream; | |
8 | |
9 /** | |
10 * Tests locale translation download. | |
11 * | |
12 * @group locale | |
13 */ | |
14 class LocaleTranslationDownloadTest extends LocaleUpdateBase { | |
15 | |
16 /** | |
17 * The virtual file stream for storing translations. | |
18 * | |
19 * @var \org\bovigo\vfs\vfsStreamDirectory | |
20 */ | |
21 protected $translationsStream; | |
22 | |
23 /** | |
24 * {@inheritdoc} | |
25 */ | |
26 protected function setUp() { | |
27 parent::setUp(); | |
28 $moduleHandler = $this->container->get('module_handler'); | |
29 $moduleHandler->loadInclude('locale', 'inc', 'locale.batch'); | |
30 ConfigurableLanguage::createFromLangcode('de')->save(); | |
31 | |
32 // Let the translations:// stream wrapper point to a virtual file system to | |
33 // make it independent from the test environment. | |
34 $this->translationsStream = vfsStream::setup('translations'); | |
35 \Drupal::configFactory()->getEditable('locale.settings') | |
36 ->set('translation.path', $this->translationsStream->url()) | |
37 ->save(); | |
38 } | |
39 | |
40 /** | |
41 * Tests translation download from remote sources. | |
42 */ | |
43 public function testUpdateImportSourceRemote() { | |
44 | |
45 // Provide remote and 'previously' downloaded translation file. | |
46 $this->setTranslationFiles(); | |
47 vfsStream::create([ | |
48 'contrib_module_one-8.x-1.1.de._po' => '__old_content__', | |
49 ], $this->translationsStream); | |
50 | |
51 $url = \Drupal::service('url_generator')->generateFromRoute('<front>', [], ['absolute' => TRUE]); | |
52 $uri = $url . PublicStream::basePath() . '/remote/8.x/contrib_module_one/contrib_module_one-8.x-1.1.de._po'; | |
53 $source_file = (object) [ | |
54 'uri' => $uri, | |
55 ]; | |
56 | |
57 $result = locale_translation_download_source($source_file, 'translations://'); | |
58 | |
59 $this->assertEquals('translations://contrib_module_one-8.x-1.1.de._po', $result->uri); | |
60 $this->assertFalse(file_exists('translations://contrib_module_one-8.x-1.1.de_0._po')); | |
61 $this->assertTrue(file_exists('translations://contrib_module_one-8.x-1.1.de._po')); | |
62 $this->assertNotContains('__old_content__', file_get_contents('translations://contrib_module_one-8.x-1.1.de._po')); | |
63 } | |
64 | |
65 } |