public function FormatterTest::testFloatAndNumeric 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::testFloatAndNumeric()
Test callback.
File
- tests/
src/ FunctionalJavascript/ FormatterTest.php, line 214
Class
- FormatterTest
- A tests for Double Field formatter.
Namespace
Drupal\Tests\double_field\FunctionalJavascriptCode
public function testFloatAndNumeric() : void {
$settings = [];
$settings['storage']['first']['type'] = 'float';
$settings['storage']['second']['type'] = 'numeric';
$settings['formatter']['type'] = 'double_field_unformatted_list';
$this
->createField($settings);
$this
->drupalGet($this->displayAdminPath);
$expected_summary = [
'Display as inline element',
'<b>First subfield - float</b>',
'Hidden: no',
'Number format: 1234.12',
'<b>Second subfield - decimal</b>',
'Hidden: no',
'Number format: 1234.12',
];
$this
->assertSettingsSummary($expected_summary);
$this
->openSettingsForm();
$page = $this
->getSession()
->getPage();
$details_1 = $page
->find('xpath', '//details[1]');
$details_1
->click();
$details_1
->selectFieldOption("Thousand marker", 'Space');
$details_1
->selectFieldOption("Decimal marker", 'Comma');
$details_1
->fillField('Scale', 1);
$details_2 = $page
->find('xpath', '//details[2]');
$details_2
->click();
$details_2
->selectFieldOption("Thousand marker", 'Space');
$details_2
->selectFieldOption("Decimal marker", 'Comma');
$details_2
->fillField('Scale', 3);
$this
->submitSettingsForm();
$expected_summary = [
'Display as inline element',
'<b>First subfield - float</b>',
'Hidden: no',
'Number format: 1 234,1',
'<b>Second subfield - decimal</b>',
'Hidden: no',
'Number format: 1 234,123',
];
$this
->assertSettingsSummary($expected_summary);
$this
->submitNode([
3456789.3,
612345,
]);
$prefix = '//div[contains(@class, "double-field-unformatted-list")]';
$this
->assertXpath($prefix . '/div[@class = "double-field-first" and text() = "3 456 789,3"]');
$this
->assertXpath($prefix . '/div[@class = "double-field-second" and text() = "612 345,000"]');
}