You are here

protected function FormErrorHandlerTest::setUp in Drupal 8

Same name in this branch
  1. 8 core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php \Drupal\Tests\Core\Form\FormErrorHandlerTest::setUp()
  2. 8 core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php \Drupal\Tests\inline_form_errors\Unit\FormErrorHandlerTest::setUp()

Overrides UnitTestCase::setUp

File

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

Class

FormErrorHandlerTest
@coversDefaultClass \Drupal\inline_form_errors\FormErrorHandler @group InlineFormErrors

Namespace

Drupal\Tests\inline_form_errors\Unit

Code

protected function setUp() {
  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',
  ];
}