public function ToggleEditableFieldsUiTest::testFieldUi in Toggle Editable fields 8
Tests the boolean formatter field UI.
Throws
\Behat\Mink\Exception\ExpectationException
File
- tests/
src/ Functional/ ToggleEditableFieldsUiTest.php, line 101
Class
- ToggleEditableFieldsUiTest
- Tests the Form mode manager user interfaces.
Namespace
Drupal\Tests\toggle_editable_fields\FunctionalCode
public function testFieldUi() {
$session = $this
->getSession();
$page = $session
->getPage();
$assert_session = $this
->assertSession();
$default_settings = [
'on' => 'On',
'off' => 'Off',
'size' => 'small',
'onstyle' => 'success',
'offstyle' => 'default',
];
$this
->drupalLogin($this->rootUser);
$this
->drupalGet("admin/structure/types/manage/{$this->nodeType1->id()}/display");
$assert_session
->statusCodeEquals(200);
$this
->assertDefaultFieldSettings();
$this
->drupalGet("admin/structure/types/manage/{$this->nodeType1->id()}/display/full");
$assert_session
->statusCodeEquals(200);
$this
->assertDefaultFieldSettings();
$this
->drupalGet("/node/{$this->nodes[1]->id()}/edit");
$page
->fillField("{$this->field['name']}[value]", 1);
$page
->pressButton('Save');
$assert_session
->statusCodeEquals(200);
$toggle_checkbox = $this
->assertSession()
->elementExists('xpath', '//input[contains(@data-toggle, "toggle")]');
foreach (array_keys($default_settings) as $key) {
$this
->assertTrue($toggle_checkbox
->hasAttribute("data-{$key}"), new FormattableMarkup('Default data attribute %key found.', [
'%key' => "data-{$key}",
]));
}
}