TYPO3 CMS  TYPO3_7-6
RequiredValidatorTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
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.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $subjectClassName = \TYPO3\CMS\Form\Domain\Validator\RequiredValidator::class;
26 
30  public function validDataProvider()
31  {
32  return [
33  'string "a"' => ['a'],
34  'string "a b"' => ['a b'],
35  'string "0"' => ['0'],
36  'value 0' => [0],
37  'array with string "a"' => [['a']],
38  'array with string "a b"' => [['a b']],
39  'array with string "0"' => [['0']],
40  'array with value 0' => [[0]],
41  'array with strings "a" and "b"' => [['a', 'b']],
42  'array with empty string and "a"' => [['', 'a']],
43  'array with empty string and "0"' => [['', '0']],
44  'array with empty string and 0' => [['', 0]],
45  ];
46  }
47 
51  public function invalidDataProvider()
52  {
53  return [
54  'empty string' => [''],
55  'array with empty string' => [['']],
56  'array with empty strings' => [['', '']]
57  ];
58  }
59 
65  {
66  $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error')];
67  $subject = $this->createSubject($options);
68 
69  $this->assertEmpty(
70  $subject->validate($input)->getErrors()
71  );
72  }
73 
79  {
80  $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error')];
81  $subject = $this->createSubject($options);
82 
83  $this->assertNotEmpty(
84  $subject->validate($input)->getErrors()
85  );
86  }
87 }