class LanguageTest in Drupal 8
Same name in this branch
- 8 core/modules/ckeditor/tests/src/Unit/Plugin/CKEditorPlugin/LanguageTest.php \Drupal\Tests\ckeditor\Unit\Plugin\CKEditorPlugin\LanguageTest
- 8 core/modules/language/tests/src/Kernel/Plugin/migrate/source/LanguageTest.php \Drupal\Tests\language\Kernel\Plugin\migrate\source\LanguageTest
Same name and namespace in other branches
- 9 core/modules/ckeditor/tests/src/Unit/Plugin/CKEditorPlugin/LanguageTest.php \Drupal\Tests\ckeditor\Unit\Plugin\CKEditorPlugin\LanguageTest
- 10 core/modules/ckeditor/tests/src/Unit/Plugin/CKEditorPlugin/LanguageTest.php \Drupal\Tests\ckeditor\Unit\Plugin\CKEditorPlugin\LanguageTest
@coversDefaultClass \Drupal\ckeditor\Plugin\CKEditorPlugin\Language
@group ckeditor
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\ckeditor\Unit\Plugin\CKEditorPlugin\LanguageTest
Expanded class hierarchy of LanguageTest
File
- core/
modules/ ckeditor/ tests/ src/ Unit/ Plugin/ CKEditorPlugin/ LanguageTest.php, line 14
Namespace
Drupal\Tests\ckeditor\Unit\Plugin\CKEditorPluginView source
class LanguageTest extends UnitTestCase {
/**
* The plugin under test.
*
* @var \Drupal\ckeditor\Plugin\CKEditorPlugin\Language
*/
protected $plugin;
/**
* {@inheritdoc}
*/
public function setUp() {
$this->plugin = new Language([], $this
->randomMachineName(), []);
}
/**
* Provides a list of configs to test.
*/
public function providerGetConfig() {
return [
[
'un',
count(LanguageManager::getUnitedNationsLanguageList()),
],
[
'all',
count(LanguageManager::getStandardLanguageList()),
],
];
}
/**
* @covers ::getConfig
*
* @dataProvider providerGetConfig
*/
public function testGetConfig($language_list, $expected_number) {
$editor = $this
->getMockBuilder('Drupal\\editor\\Entity\\Editor')
->disableOriginalConstructor()
->getMock();
$editor
->expects($this
->once())
->method('getSettings')
->willReturn([
'plugins' => [
'language' => [
'language_list' => $language_list,
],
],
]);
$config = $this->plugin
->getConfig($editor);
$this
->assertIsArray($config);
$this
->assertContains('ar:Arabic:rtl', $config['language_list']);
$this
->assertContains('zh-hans:Chinese, Simplified', $config['language_list']);
$this
->assertContains('en:English', $config['language_list']);
$this
->assertContains('fr:French', $config['language_list']);
$this
->assertContains('ru:Russian', $config['language_list']);
$this
->assertContains('ar:Arabic:rtl', $config['language_list']);
$this
->assertEquals($expected_number, count($config['language_list']));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LanguageTest:: |
protected | property | The plugin under test. | |
LanguageTest:: |
public | function | Provides a list of configs to test. | |
LanguageTest:: |
public | function |
Overrides UnitTestCase:: |
|
LanguageTest:: |
public | function | @covers ::getConfig | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed 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. |