2 namespace TYPO3\CMS\Form\Tests\Unit\Validator
;
5 * This file is part of the TYPO3 CMS project.
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
20 class RequiredValidatorTest
extends AbstractValidatorTest
25 protected $subjectClassName = \TYPO3\CMS\Form\Domain\Validator\RequiredValidator
::class;
30 public function validDataProvider()
33 'string "a"' => array('a'),
34 'string "a b"' => array('a b'),
35 'string "0"' => array('0'),
36 'value 0' => array(0),
37 'array with string "a"' => array(array('a')),
38 'array with string "a b"' => array(array('a b')),
39 'array with string "0"' => array(array('0')),
40 'array with value 0' => array(array(0)),
41 'array with strings "a" and "b"' => array(array('a', 'b')),
42 'array with empty string and "a"' => array(array('', 'a')),
43 'array with empty string and "0"' => array(array('', "0")),
44 'array with empty string and 0' => array(array('', 0)),
51 public function invalidDataProvider()
54 'empty string' => array(''),
55 'array with empty string' => array(array('')),
56 'array with empty strings' => array(array('', ''))
62 * @dataProvider validDataProvider
64 public function validateForValidDataHasEmptyErrorResult($input)
66 $options = array('element' => uniqid('test'), 'errorMessage' => uniqid('error'));
67 $subject = $this->createSubject($options);
70 $subject->validate($input)->getErrors()
76 * @dataProvider invalidDataProvider
78 public function validateForInvalidDataHasNotEmptyErrorResult($input)
80 $options = array('element' => uniqid('test'), 'errorMessage' => uniqid('error'));
81 $subject = $this->createSubject($options);
83 $this->assertNotEmpty(
84 $subject->validate($input)->getErrors()