public function FormatterTest::testTabsFormatter in Double Field 8.3
Test callback.
File
- tests/
src/ FunctionalJavascript/ FormatterTest.php, line 417
Class
- FormatterTest
- A tests for Double Field formatter.
Namespace
Drupal\Tests\double_field\FunctionalJavascriptCode
public function testTabsFormatter() : void {
$page = $this
->getSession()
->getPage();
$settings = [];
$settings['storage']['cardinality'] = 3;
$settings['storage']['first']['type'] = 'string';
$settings['storage']['second']['type'] = 'string';
$settings['formatter']['type'] = 'double_field_tabs';
$this
->createField($settings);
$this
->submitNode([
'Foo 1',
'Foo 2',
], [
'Bar 1',
'Bar 2',
], [
'Qux 1',
'Qux 2',
]);
$this
->drupalGet('node/1');
$wrapper = $page
->find('xpath', '//div[contains(@class, "field--type-double-field")]/div/div[contains(@class, "double-field-tabs")]');
self::assertNotNull($wrapper);
$links = $wrapper
->findAll('xpath', '/ul[@role = "tablist"]/li[@role ="tab"]/a');
self::assertCount(3, $links);
self::assertEquals('Foo 1', $links[0]
->getText());
self::assertEquals('Bar 1', $links[1]
->getText());
self::assertEquals('Qux 1', $links[2]
->getText());
$panels = $wrapper
->findAll('xpath', '/div[@role = "tabpanel"]');
self::assertCount(3, $panels);
self::assertEquals('Foo 2', $panels[0]
->getText());
self::assertTrue($panels[0]
->isVisible());
self::assertFalse($panels[1]
->isVisible());
self::assertFalse($panels[2]
->isVisible());
$links[1]
->click();
self::assertEquals('Bar 2', $panels[1]
->getText());
self::assertFalse($panels[0]
->isVisible());
self::assertTrue($panels[1]
->isVisible());
self::assertFalse($panels[2]
->isVisible());
$links[2]
->click();
self::assertEquals('Qux 2', $panels[2]
->getText());
self::assertFalse($panels[0]
->isVisible());
self::assertFalse($panels[1]
->isVisible());
self::assertTrue($panels[2]
->isVisible());
}