class LanguageTest in Drupal 9
Same name in this branch
- 9 core/modules/ckeditor/tests/src/Unit/Plugin/CKEditorPlugin/LanguageTest.php \Drupal\Tests\ckeditor\Unit\Plugin\CKEditorPlugin\LanguageTest
- 9 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
- 8 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 \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, PhpUnitCompatibilityTrait, PhpUnitWarnings
- 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() : void {
$this->plugin = new Language([], $this
->randomMachineName(), []);
}
/**
* Provides a list of configs to test.
*/
public function providerGetConfig() {
return [
[
'un',
LanguageManager::getUnitedNationsLanguageList(),
],
[
'all',
LanguageManager::getStandardLanguageList(),
],
];
}
/**
* @covers ::getConfig
*
* @dataProvider providerGetConfig
*/
public function testGetConfig($language_list, $expected_languages) {
$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
->assertSameSize($expected_languages, $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 | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
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 | 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. | |
UnitTestCase:: |
public static | function |