You are here

class LanguageTest in Drupal 9

Same name in this branch
  1. 9 core/modules/ckeditor/tests/src/Unit/Plugin/CKEditorPlugin/LanguageTest.php \Drupal\Tests\ckeditor\Unit\Plugin\CKEditorPlugin\LanguageTest
  2. 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
  1. 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

Expanded class hierarchy of LanguageTest

File

core/modules/ckeditor/tests/src/Unit/Plugin/CKEditorPlugin/LanguageTest.php, line 14

Namespace

Drupal\Tests\ckeditor\Unit\Plugin\CKEditorPlugin
View 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

Namesort descending Modifiers Type Description Overrides
LanguageTest::$plugin protected property The plugin under test.
LanguageTest::providerGetConfig public function Provides a list of configs to test.
LanguageTest::setUp public function Overrides UnitTestCase::setUp
LanguageTest::testGetConfig public function @covers ::getConfig
PhpUnitWarnings::$deprecationWarnings private static property Deprecation warnings from PHPUnit to raise with @trigger_error().
PhpUnitWarnings::addWarning public function Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals Deprecated protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUpBeforeClass public static function