function TranslationsTest::testMediaLibraryTranslations
Same name in other branches
- 9 core/modules/media_library/tests/src/FunctionalJavascript/TranslationsTest.php \Drupal\Tests\media_library\FunctionalJavascript\TranslationsTest::testMediaLibraryTranslations()
- 10 core/modules/media_library/tests/src/FunctionalJavascript/TranslationsTest.php \Drupal\Tests\media_library\FunctionalJavascript\TranslationsTest::testMediaLibraryTranslations()
- 11.x core/modules/media_library/tests/src/FunctionalJavascript/TranslationsTest.php \Drupal\Tests\media_library\FunctionalJavascript\TranslationsTest::testMediaLibraryTranslations()
Tests the media library widget shows all media only once.
File
-
core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ TranslationsTest.php, line 120
Class
- TranslationsTest
- Tests media library for translatable media.
Namespace
Drupal\Tests\media_library\FunctionalJavascriptCode
public function testMediaLibraryTranslations() {
$assert_session = $this->assertSession();
$page = $this->getSession()
->getPage();
// All translations should be shown in the administration overview,
// regardless of the interface language.
$this->drupalGet('nl/admin/content/media-grid');
$assert_session->elementsCount('css', '.js-media-library-item', 6);
$media_items = $page->findAll('css', '.media-library-item__name');
$media_names = [];
foreach ($media_items as $media_item) {
$media_names[] = $media_item->getText();
}
sort($media_names);
$this->assertSame([
'Ardilla',
'Eekhoorn',
'Hert',
'Tejón',
'Vos',
'Zorro',
], $media_names);
$this->drupalGet('es/admin/content/media-grid');
$assert_session->elementsCount('css', '.js-media-library-item', 6);
$media_items = $page->findAll('css', '.media-library-item__name');
$media_names = [];
foreach ($media_items as $media_item) {
$media_names[] = $media_item->getText();
}
sort($media_names);
$this->assertSame([
'Ardilla',
'Eekhoorn',
'Hert',
'Tejón',
'Vos',
'Zorro',
], $media_names);
// All media should only be shown once, and should be shown in the interface
// language.
$this->drupalGet('nl/node/add/article');
$assert_session->elementExists('css', '.js-media-library-open-button[name^="field_media"]')
->click();
$assert_session->waitForText('Add or select media');
$assert_session->elementsCount('css', '.js-media-library-item', 4);
$media_items = $page->findAll('css', '.media-library-item__name');
$media_names = [];
foreach ($media_items as $media_item) {
$media_names[] = $media_item->getText();
}
sort($media_names);
$this->assertSame([
'Eekhoorn',
'Hert',
'Tejón',
'Vos',
], $media_names);
$this->drupalGet('es/node/add/article');
$assert_session->elementExists('css', '.js-media-library-open-button[name^="field_media"]')
->click();
$assert_session->waitForText('Add or select media');
$assert_session->elementsCount('css', '.js-media-library-item', 4);
$media_items = $page->findAll('css', '.media-library-item__name');
$media_names = [];
foreach ($media_items as $media_item) {
$media_names[] = $media_item->getText();
}
sort($media_names);
$this->assertSame([
'Ardilla',
'Hert',
'Tejón',
'Zorro',
], $media_names);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.