function CKEditor5Test::getVerticalTabs
Same name in other branches
- 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Test::getVerticalTabs()
- 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Test::getVerticalTabs()
Gets the titles of the vertical tabs in the given container.
Parameters
string $container_selector: The container in which to look for vertical tabs.
bool $visible_only: (optional) Whether to restrict to only the visible vertical tabs. TRUE by default.
Return value
string[] The titles of all vertical tabs menu items, restricted to only visible ones by default.
Throws
\LogicException
1 call to CKEditor5Test::getVerticalTabs()
- CKEditor5Test::testActiveTabsMaintained in core/
modules/ ckeditor5/ tests/ src/ FunctionalJavascript/ CKEditor5Test.php - Confirms active tab status is intact after AJAX refresh.
File
-
core/
modules/ ckeditor5/ tests/ src/ FunctionalJavascript/ CKEditor5Test.php, line 283
Class
- CKEditor5Test
- Tests for CKEditor 5.
Namespace
Drupal\Tests\ckeditor5\FunctionalJavascriptCode
private function getVerticalTabs(string $container_selector, bool $visible_only = TRUE) : array {
$page = $this->getSession()
->getPage();
// Ensure the container exists.
$container = $page->find('css', $container_selector);
if ($container === NULL) {
throw new \LogicException('The given container should exist.');
}
// Make sure that the container selector contains exactly one Vertical Tabs
// UI component.
$vertical_tabs = $container->findAll('css', '.vertical-tabs');
if (count($vertical_tabs) != 1) {
throw new \LogicException('The given container should contain exactly one Vertical Tabs component.');
}
$vertical_tabs = $container->findAll('css', '.vertical-tabs__menu-item');
$vertical_tabs_titles = [];
foreach ($vertical_tabs as $vertical_tab) {
if ($visible_only && !$vertical_tab->isVisible()) {
continue;
}
$title = $vertical_tab->find('css', '.vertical-tabs__menu-item-title')
->getHtml();
// When retrieving visible vertical tabs, mark the selected one.
if ($visible_only && $vertical_tab->hasClass('is-selected')) {
$title = "➡️{$title}";
}
$vertical_tabs_titles[] = $title;
}
return $vertical_tabs_titles;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.