function FormErrorHandlerTest::setUp

Same name in this branch
  1. 9 core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php \Drupal\Tests\Core\Form\FormErrorHandlerTest::setUp()
Same name and namespace in other branches
  1. 8.9.x core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php \Drupal\Tests\inline_form_errors\Unit\FormErrorHandlerTest::setUp()
  2. 8.9.x core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php \Drupal\Tests\Core\Form\FormErrorHandlerTest::setUp()
  3. 10 core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php \Drupal\Tests\inline_form_errors\Unit\FormErrorHandlerTest::setUp()
  4. 10 core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php \Drupal\Tests\Core\Form\FormErrorHandlerTest::setUp()
  5. 11.x core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php \Drupal\Tests\inline_form_errors\Unit\FormErrorHandlerTest::setUp()
  6. 11.x core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php \Drupal\Tests\Core\Form\FormErrorHandlerTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php, line 55

Class

FormErrorHandlerTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21inline_form_errors%21src%21FormErrorHandler.php/class/FormErrorHandler/9" title="Produces inline form errors." class="local">\Drupal\inline_form_errors\FormErrorHandler</a> @group InlineFormErrors

Namespace

Drupal\Tests\inline_form_errors\Unit

Code

protected function setUp() : void {
    parent::setUp();
    $this->renderer = $this->createMock(RendererInterface::class);
    $this->messenger = $this->createMock(MessengerInterface::class);
    $this->formErrorHandler = new FormErrorHandler($this->getStringTranslationStub(), $this->renderer, $this->messenger);
    $this->testForm = [
        '#parents' => [],
        '#form_id' => 'test_form',
        '#array_parents' => [],
    ];
    $this->testForm['test1'] = [
        '#type' => 'textfield',
        '#title' => 'Test 1',
        '#parents' => [
            'test1',
        ],
        '#array_parents' => [
            'test1',
        ],
        '#id' => 'edit-test1',
    ];
    $this->testForm['test2'] = [
        '#type' => 'textfield',
        '#title' => 'Test 2 & a half',
        '#parents' => [
            'test2',
        ],
        '#array_parents' => [
            'test2',
        ],
        '#id' => 'edit-test2',
    ];
    $this->testForm['fieldset'] = [
        '#parents' => [
            'fieldset',
        ],
        '#array_parents' => [
            'fieldset',
        ],
        'test3' => [
            '#type' => 'textfield',
            '#title' => 'Test 3',
            '#parents' => [
                'fieldset',
                'test3',
            ],
            '#array_parents' => [
                'fieldset',
                'test3',
            ],
            '#id' => 'edit-test3',
        ],
    ];
    $this->testForm['test4'] = [
        '#type' => 'textfield',
        '#title' => 'Test 4',
        '#parents' => [
            'test4',
        ],
        '#array_parents' => [
            'test4',
        ],
        '#id' => 'edit-test4',
        '#error_no_message' => TRUE,
    ];
    $this->testForm['test5'] = [
        '#type' => 'textfield',
        '#parents' => [
            'test5',
        ],
        '#array_parents' => [
            'test5',
        ],
        '#id' => 'edit-test5',
    ];
    $this->testForm['test6'] = [
        '#type' => 'value',
        '#title' => 'Test 6',
        '#parents' => [
            'test6',
        ],
        '#array_parents' => [
            'test6',
        ],
        '#id' => 'edit-test6',
    ];
}

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