public function WidgetTest::testBlockFieldValidation in Block field 8
Tests that validation errors from the block form are bubbled up.
File
- tests/
src/ Functional/ WidgetTest.php, line 142
Class
- WidgetTest
- Test the block field widget.
Namespace
Drupal\Tests\block_field\FunctionalCode
public function testBlockFieldValidation() {
$assert = $this
->assertSession();
$this
->drupalGet('node/add/block_node');
$this
->submitForm([
'title[0][value]' => 'Block field validation test',
'field_block[0][plugin_id]' => 'block_field_test_validation',
], 'Save');
$node = $this
->drupalGetNodeByTitle('Block field validation test');
$this
->drupalGet($node
->toUrl('edit-form'));
$this
->submitForm([
'field_block[0][settings][content]' => 'error by name',
], 'Save');
$assert
->pageTextContains('Come ere boi!');
$assert
->elementAttributeContains('css', 'input[name="field_block[0][settings][content]"]', 'class', 'error');
$this
->submitForm([
'field_block[0][settings][content]' => 'error by element',
], 'Save');
$assert
->pageTextContains('Gimmie them toez!');
$assert
->elementAttributeContains('css', 'input[name="field_block[0][settings][content]"]', 'class', 'error');
$this
->submitForm([
'field_block[0][settings][content]' => 'something else',
], 'Save');
$assert
->pageTextContains('Block node Block field validation test has been updated.');
}