class InstallTranslationFilePatternTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/tests/src/Unit/Installer/InstallTranslationFilePatternTest.php \Drupal\Tests\system\Unit\Installer\InstallTranslationFilePatternTest
Tests for installer language support.
@group Installer
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\system\Unit\Installer\InstallTranslationFilePatternTest
Expanded class hierarchy of InstallTranslationFilePatternTest
File
- core/
modules/ system/ tests/ src/ Unit/ Installer/ InstallTranslationFilePatternTest.php, line 18 - Contains \Drupal\Tests\system\Unit\Installer\InstallTranslationFilePatternTest.
Namespace
Drupal\Tests\system\Unit\InstallerView source
class InstallTranslationFilePatternTest extends UnitTestCase {
/**
* @var \Drupal\Core\StringTranslation\Translator\FileTranslation
*/
protected $fileTranslation;
/**
* @var \ReflectionMethod
*/
protected $filePatternMethod;
/**
* {@inheritdoc}
*/
protected function setup() {
parent::setUp();
$this->fileTranslation = new FileTranslation('filename');
$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 array(
array(
'hu',
'drupal-8.0.0-alpha1.hu.po',
),
array(
'ta',
'drupal-8.10.10-beta12.ta.po',
),
array(
'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 array(
array(
'hu',
'drupal-alpha1-*-hu.po',
),
array(
'ta',
'drupal-beta12.ta',
),
array(
'hi',
'drupal-hi.po',
),
array(
'de',
'drupal-dummy-de.po',
),
array(
'hu',
'drupal-10.0.1.alpha1-hu.po',
),
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InstallTranslationFilePatternTest:: |
protected | property | ||
InstallTranslationFilePatternTest:: |
protected | property | ||
InstallTranslationFilePatternTest:: |
public | function | ||
InstallTranslationFilePatternTest:: |
public | function | ||
InstallTranslationFilePatternTest:: |
protected | function | ||
InstallTranslationFilePatternTest:: |
public | function | @dataProvider providerInvalidTranslationFiles | |
InstallTranslationFilePatternTest:: |
public | function | @dataProvider providerValidTranslationFiles | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 259 |