function WorkspaceFormValidationTest::testValidateLimitErrors

Same name and namespace in other branches
  1. main core/modules/workspaces/tests/src/Functional/WorkspaceFormValidationTest.php \Drupal\Tests\workspaces\Functional\WorkspaceFormValidationTest::testValidateLimitErrors()

Tests partial form validation through #limit_validation_errors.

File

core/modules/workspaces/tests/src/Functional/WorkspaceFormValidationTest.php, line 48

Class

WorkspaceFormValidationTest
Tests Workspaces form validation.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testValidateLimitErrors() : void {
  $this->createAndActivateWorkspaceThroughUi();
  $edit = [
    'test' => 'test1',
    'test_numeric_index[0]' => 'test2',
    'test_substring[foo]' => 'test3',
  ];
  $path = 'form-test/limit-validation-errors';
  // Submit the form by pressing all the 'Partial validate' buttons.
  $this->drupalGet($path);
  $this->submitForm($edit, 'Partial validate');
  $this->assertSession()
    ->pageTextContains('This form can only be submitted in the default workspace.');
  $this->drupalGet($path);
  $this->submitForm($edit, 'Partial validate (numeric index)');
  $this->assertSession()
    ->pageTextContains('This form can only be submitted in the default workspace.');
  $this->drupalGet($path);
  $this->submitForm($edit, 'Partial validate (substring)');
  $this->assertSession()
    ->pageTextContains('This form can only be submitted in the default workspace.');
  // Now test full form validation.
  $this->drupalGet($path);
  $this->submitForm($edit, 'Full validate');
  $this->assertSession()
    ->pageTextContains('This form can only be submitted in the default workspace.');
}

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