class InstallTranslationFilePatternTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php \Drupal\Tests\system\Kernel\Installer\InstallTranslationFilePatternTest
- 10 core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php \Drupal\Tests\system\Kernel\Installer\InstallTranslationFilePatternTest
- 8.9.x core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php \Drupal\Tests\system\Kernel\Installer\InstallTranslationFilePatternTest
Tests for installer language support.
@group Installer
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Kernel\Installer\InstallTranslationFilePatternTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of InstallTranslationFilePatternTest
File
-
core/
modules/ system/ tests/ src/ Kernel/ Installer/ InstallTranslationFilePatternTest.php, line 13
Namespace
Drupal\Tests\system\Kernel\InstallerView source
class InstallTranslationFilePatternTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
];
/**
* @var \Drupal\Core\StringTranslation\Translator\FileTranslation
*/
protected $fileTranslation;
/**
* @var \ReflectionMethod
*/
protected $filePatternMethod;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->fileTranslation = new FileTranslation('filename', $this->container
->get('file_system'));
$method = new \ReflectionMethod('\\Drupal\\Core\\StringTranslation\\Translator\\FileTranslation', 'getTranslationFilesPattern');
$method->setAccessible(TRUE);
$this->filePatternMethod = $method;
}
/**
* @dataProvider providerValidTranslationFiles
*/
public function testFilesPatternValid($langcode, $filename) {
$pattern = $this->filePatternMethod
->invoke($this->fileTranslation, $langcode);
$this->assertNotEmpty(preg_match($pattern, $filename));
}
/**
* @return array
*/
public function providerValidTranslationFiles() {
return [
[
'hu',
'drupal-8.0.0-alpha1.hu.po',
],
[
'ta',
'drupal-8.10.10-beta12.ta.po',
],
[
'hi',
'drupal-8.0.0.hi.po',
],
];
}
/**
* @dataProvider providerInvalidTranslationFiles
*/
public function testFilesPatternInvalid($langcode, $filename) {
$pattern = $this->filePatternMethod
->invoke($this->fileTranslation, $langcode);
$this->assertEmpty(preg_match($pattern, $filename));
}
/**
* @return array
*/
public function providerInvalidTranslationFiles() {
return [
[
'hu',
'drupal-alpha1-*-hu.po',
],
[
'ta',
'drupal-beta12.ta',
],
[
'hi',
'drupal-hi.po',
],
[
'de',
'drupal-dummy-de.po',
],
[
'hu',
'drupal-10.0.1.alpha1-hu.po',
],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.