function CKEditor5Test::languageOfPartsPluginTestHelper

Same name in other branches
  1. 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Test::languageOfPartsPluginTestHelper()
  2. 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Test::languageOfPartsPluginTestHelper()

Validate expected languages available in editor.

1 call to CKEditor5Test::languageOfPartsPluginTestHelper()
CKEditor5Test::testLanguageOfPartsPlugin in core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
Test for Language of Parts plugin.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php, line 242

Class

CKEditor5Test
Tests for CKEditor 5.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

public function languageOfPartsPluginTestHelper($page, $assert_session, $configured_languages) {
    $this->drupalGet('node/add/page');
    $this->assertNotEmpty($assert_session->waitForText('Choose language'));
    // Click on the dropdown button.
    $page->find('css', '.ck-text-fragment-language-dropdown button')
        ->click();
    // Get all the languages available in dropdown.
    $current_languages = $page->findAll('css', '.ck-text-fragment-language-dropdown li .ck-button__label');
    // Remove "Remove language" element from current languages.
    array_shift($current_languages);
    // Create array of full language name.
    $languages = [];
    foreach ($current_languages as $item) {
        $languages[] = $item->getText();
    }
    // Return the values from a single column.
    $configured_languages = array_column($configured_languages, 0);
    // Sort on full language name.
    asort($configured_languages);
    $this->assertSame(array_values($configured_languages), $languages);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.