public function HorizontalTabsLabelsTest::testHorizontalTabsLabels in Field Group 8.3
Tests horizontal tabs labels.
@dataProvider providerTestHorizontalTabsLabels
File
- tests/
src/ FunctionalJavascript/ HorizontalTabsLabelsTest.php, line 189
Class
- HorizontalTabsLabelsTest
- Tests horizontal tabs labels.
Namespace
Drupal\Tests\field_group\FunctionalJavascriptCode
public function testHorizontalTabsLabels(string $theme_name) {
if ($theme_name !== $this->defaultTheme) {
$theme_installer = \Drupal::service('theme_installer');
assert($theme_installer instanceof ThemeInstallerInterface);
try {
$theme_installer
->install([
$theme_name,
], TRUE);
} catch (UnknownExtensionException $ex) {
// Themes might be missing, e.g Drupal 8.x does not have stable9 theme.
$this
->pass("The {$theme_name} theme does not exist in the current test environment.");
return;
}
\Drupal::configFactory()
->getEditable('system.theme')
->set('default', $theme_name)
->set('admin', $theme_name)
->save();
}
if (!in_array($theme_name, $this->themesWithBlocks, TRUE)) {
$this
->drupalPlaceBlock('page_title_block', [
'region' => 'content',
]);
$this
->drupalPlaceBlock('local_tasks_block', [
'region' => 'content',
'weight' => 1,
]);
$this
->drupalPlaceBlock('local_actions_block', [
'region' => 'content',
'weight' => 2,
]);
$this
->drupalPlaceBlock('system_main_block', [
'region' => 'content',
'weight' => 3,
]);
}
$this
->drupalLogin($this->rootUser);
// Actual test: check the node edit page. Tab1 and Tab2 should be present.
$this
->drupalGet(Url::fromRoute('node.add', [
'node_type' => $this->testNodeType
->id(),
]));
$this
->assertHorizontalTabsLabels();
// Create a node.
$this->page
->fillField('title[0][value]', 'Field Group Horizontal Tabs Test Node');
$this->page
->fillField('Test label', 'Test label');
$this
->assertNotNull($tab2 = $this->page
->find('css', '.js .field-group-tabs-wrapper a[href="#edit-group-tab2"]'));
$tab2
->click();
$this->assertSession
->waitForElementVisible('css', '[name="body[0][value]"]');
$this->page
->fillField('body[0][value]', 'Donec laoreet imperdiet.');
$this->page
->findButton('edit-submit')
->click();
$this->assertSession
->waitForElement('css', 'html.js [data-drupal-messages]');
$status_message = $this->page
->find('css', 'html.js [data-drupal-messages]');
$this
->assertStringContainsString("{$this->testNodeType->label()} Field Group Horizontal Tabs Test Node has been created.", $status_message
->getText());
// Check the node.
$this
->drupalGet(Url::fromRoute('entity.node.canonical', [
'node' => '1',
]));
$this
->assertHorizontalTabsLabels();
$this
->drupalLogout();
// Retest the node with anonymous user.
$this
->drupalGet(Url::fromRoute('entity.node.canonical', [
'node' => '1',
]));
$this
->assertHorizontalTabsLabels();
}