public function FormatterTest::testDetailsFormatter in Double Field 4.x
Same name and namespace in other branches
- 8.3 tests/src/FunctionalJavascript/FormatterTest.php \Drupal\Tests\double_field\FunctionalJavascript\FormatterTest::testDetailsFormatter()
Test callback.
File
- tests/
src/ FunctionalJavascript/ FormatterTest.php, line 399
Class
- FormatterTest
- A tests for Double Field formatter.
Namespace
Drupal\Tests\double_field\FunctionalJavascriptCode
public function testDetailsFormatter() : void {
$page = $this
->getSession()
->getPage();
$settings = [];
$settings['storage']['first']['type'] = 'string';
$settings['storage']['second']['type'] = 'string';
$settings['formatter']['type'] = 'double_field_details';
$this
->createField($settings);
$this
->submitNode([
'Foo 1',
'Foo 2',
]);
$this
->drupalGet('node/1');
$xpath = '//div[contains(@class, "field--type-double-field")]';
$xpath .= '//details[contains(@class, "double-field-detail") and @open]';
$xpath .= '/summary[text() = "Foo 1"][1]';
$xpath .= '/following-sibling::div[@class = "details-wrapper" and normalize-space() = "Foo 2"]';
$this
->assertXpath($xpath);
$this
->drupalGet($this->displayAdminPath);
$expected_summary = [
'Open: yes',
'<b>First subfield - text</b>',
'Hidden: no',
'<b>Second subfield - text</b>',
'Hidden: no',
];
$this
->assertSettingsSummary($expected_summary);
$this
->openSettingsForm();
$this
->assertXpath('//input[@type = "checkbox" and @name = "fields[{field_name}][settings_edit_form][settings][open]" and @checked]');
$page
->uncheckField("Open");
$this
->submitSettingsForm();
$expected_summary = [
'Open: no',
'<b>First subfield - text</b>',
'Hidden: no',
'<b>Second subfield - text</b>',
'Hidden: no',
];
$this
->assertSettingsSummary($expected_summary);
$this
->drupalGet('node/1');
$xpath = '//div[contains(@class, "field--type-double-field")]';
$xpath .= '/details[contains(@class, "double-field-detail") and not(@open)]';
$xpath .= '/summary[text() = "Foo 1"][1]';
$xpath .= '/following-sibling::div[@class = "details-wrapper" and normalize-space() = "Foo 2"]';
$this
->assertXpath($xpath);
}