public function FormatterTest::testEmailAndTelephone 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::testEmailAndTelephone()
Test callback.
File
- tests/
src/ FunctionalJavascript/ FormatterTest.php, line 272
Class
- FormatterTest
- A tests for Double Field formatter.
Namespace
Drupal\Tests\double_field\FunctionalJavascriptCode
public function testEmailAndTelephone() : void {
$settings = [];
$settings['storage']['first']['type'] = 'email';
$settings['storage']['second']['type'] = 'telephone';
$settings['formatter']['type'] = 'double_field_unformatted_list';
$this
->createField($settings);
$this
->drupalGet($this->displayAdminPath);
$expected_summary = [
'Display as inline element',
'<b>First subfield - email</b>',
'Link: no',
'Hidden: no',
'<b>Second subfield - telephone</b>',
'Link: no',
'Hidden: no',
];
$this
->assertSettingsSummary($expected_summary);
// Make sure the values are not rendered as links.
$this
->submitNode([
'admin@localhost',
'+71234567889',
]);
$prefix = '//div[contains(@class, "double-field-unformatted-list")]';
$this
->assertXpath($prefix . '//div[@class = "double-field-first" and text() = "admin@localhost"]');
$this
->assertXpath($prefix . '//div[@class = "double-field-second" and text() = "+71234567889"]');
$this
->drupalGet($this->displayAdminPath);
$this
->openSettingsForm();
$page = $this
->getSession()
->getPage();
$details_1 = $page
->find('xpath', '//details[1]');
$details_1
->click();
$details_1
->checkField('Display as link');
$details_2 = $page
->find('xpath', '//details[2]');
$details_2
->click();
$details_2
->checkField('Display as link');
$this
->submitSettingsForm();
$expected_summary = [
'Display as inline element',
'<b>First subfield - email</b>',
'Link: yes',
'Hidden: no',
'<b>Second subfield - telephone</b>',
'Link: yes',
'Hidden: no',
];
$this
->assertSettingsSummary($expected_summary);
$this
->drupalGet('node/1');
$prefix = '//div[contains(@class, "double-field-unformatted-list")]';
$this
->assertXpath($prefix . '/div[@class = "double-field-first"]/a[@href = "mailto:admin@localhost" and text() = "admin@localhost"]');
$this
->assertXpath($prefix . '/div[@class = "double-field-second"]/a[@href = "tel:%2B71234567889" and text() = "+71234567889"]');
}