public function FormValidatorTest::testRequiredErrorMessage in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php \Drupal\Tests\Core\Form\FormValidatorTest::testRequiredErrorMessage()
@covers ::doValidateForm
@dataProvider providerTestRequiredErrorMessage
File
- core/
tests/ Drupal/ Tests/ Core/ Form/ FormValidatorTest.php, line 304 - Contains \Drupal\Tests\Core\Form\FormValidatorTest.
Class
- FormValidatorTest
- @coversDefaultClass \Drupal\Core\Form\FormValidator @group Form
Namespace
Drupal\Tests\Core\FormCode
public function testRequiredErrorMessage($element, $expected_message) {
$form_validator = $this
->getMockBuilder('Drupal\\Core\\Form\\FormValidator')
->setConstructorArgs([
new RequestStack(),
$this
->getStringTranslationStub(),
$this->csrfToken,
$this->logger,
$this->formErrorHandler,
])
->setMethods(array(
'executeValidateHandlers',
))
->getMock();
$form_validator
->expects($this
->once())
->method('executeValidateHandlers');
$form = array();
$form['test'] = $element + array(
'#type' => 'textfield',
'#value' => '',
'#needs_validation' => TRUE,
'#required' => TRUE,
'#parents' => array(
'test',
),
);
$form_state = $this
->getMockBuilder('Drupal\\Core\\Form\\FormState')
->setMethods(array(
'setError',
))
->getMock();
$form_state
->expects($this
->once())
->method('setError')
->with($this
->isType('array'), $expected_message);
$form_validator
->validateForm('test_form_id', $form, $form_state);
}