[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Tests / Unit / Mvc / Validation / EmptyValidatorTest.php
1 <?php
2 namespace TYPO3\CMS\Form\Tests\Unit\Mvc\Validation;
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
17 use TYPO3\CMS\Form\Mvc\Validation\EmptyValidator;
18
19 /**
20 * Test case
21 */
22 class EmptyValidatorTest extends \TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase
23 {
24
25 /**
26 * @test
27 */
28 public function EmptyValidatorReturnsFalseIfInputIsEmptyString()
29 {
30 $validator = $this->getMockBuilder(EmptyValidator::class)
31 ->setMethods(['translateErrorMessage'])
32 ->getMock();
33
34 $input = '';
35
36 $this->assertFalse($validator->validate($input)->hasErrors());
37 }
38
39 /**
40 * @test
41 */
42 public function EmptyValidatorReturnsFalseIfInputIsNull()
43 {
44 $validator = $this->getMockBuilder(EmptyValidator::class)
45 ->setMethods(['translateErrorMessage'])
46 ->getMock();
47
48 $input = null;
49
50 $this->assertFalse($validator->validate($input)->hasErrors());
51 }
52
53 /**
54 * @test
55 */
56 public function EmptyValidatorReturnsFalseIfInputIsEmptyArray()
57 {
58 $validator = $this->getMockBuilder(EmptyValidator::class)
59 ->setMethods(['translateErrorMessage'])
60 ->getMock();
61
62 $input = [];
63
64 $this->assertFalse($validator->validate($input)->hasErrors());
65 }
66
67 /**
68 * @test
69 */
70 public function EmptyValidatorReturnsFalseIfInputIsZero()
71 {
72 $validator = $this->getMockBuilder(EmptyValidator::class)
73 ->setMethods(['translateErrorMessage'])
74 ->getMock();
75
76 $input = 0;
77
78 $this->assertFalse($validator->validate($input)->hasErrors());
79 }
80
81 /**
82 * @test
83 */
84 public function EmptyValidatorReturnsFalseIfInputIsZeroAsString()
85 {
86 $validator = $this->getMockBuilder(EmptyValidator::class)
87 ->setMethods(['translateErrorMessage'])
88 ->getMock();
89
90 $input = '0';
91
92 $this->assertFalse($validator->validate($input)->hasErrors());
93 }
94
95 /**
96 * @test
97 */
98 public function EmptyValidatorReturnsTrueIfInputIsNonEmptyString()
99 {
100 $validator = $this->getMockBuilder(EmptyValidator::class)
101 ->setMethods(['translateErrorMessage'])
102 ->getMock();
103
104 $input = 'hellö';
105
106 $this->assertTrue($validator->validate($input)->hasErrors());
107 }
108
109 /**
110 * @test
111 */
112 public function EmptyValidatorReturnsTrueIfInputIsNonEmptyArray()
113 {
114 $validator = $this->getMockBuilder(EmptyValidator::class)
115 ->setMethods(['translateErrorMessage'])
116 ->getMock();
117
118 $input = ['hellö'];
119
120 $this->assertTrue($validator->validate($input)->hasErrors());
121 }
122 }