function BlockUiTest::testBlockValidateErrors

Same name in other branches
  1. 9 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testBlockValidateErrors()
  2. 8.9.x core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testBlockValidateErrors()
  3. 10 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testBlockValidateErrors()

Tests if validation errors are passed plugin form to the parent form.

File

core/modules/block/tests/src/Functional/BlockUiTest.php, line 354

Class

BlockUiTest
Tests that the block configuration UI exists and stores data correctly.

Namespace

Drupal\Tests\block\Functional

Code

public function testBlockValidateErrors() : void {
    $this->drupalGet('admin/structure/block/add/test_settings_validation/stark');
    $this->submitForm([
        'region' => 'content',
        'settings[digits]' => 'abc',
    ], 'Save block');
    $this->assertSession()
        ->statusMessageContains('Only digits are allowed', 'error');
    $this->assertSession()
        ->elementExists('xpath', '//div[contains(@class,"form-item-settings-digits")]/input[contains(@class,"error")]');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.