[TASK] Re-work/simplify copyright header in PHP files - Part 8
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Validation / Validator / BeforeExtbase14 / NotEmptyValidatorTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BeforeExtbase14;
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 /**
18 * Test case
19 *
20 * This testcase checks the expected behavior for Extbase < 1.4.0, to make sure
21 * we do not break backwards compatibility.
22 */
23 class NotEmptyValidatorTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
24
25 /**
26 * @test
27 */
28 public function notEmptyValidatorReturnsTrueForASimpleString() {
29 $notEmptyValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\NotEmptyValidator', array('addError'), array(), '', FALSE);
30 $notEmptyValidator->expects($this->never())->method('addError');
31 $notEmptyValidator->isValid('a not empty string');
32 }
33
34 /**
35 * @test
36 */
37 public function notEmptyValidatorReturnsFalseForAnEmptyString() {
38 $notEmptyValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\NotEmptyValidator', array('addError', 'translateErrorMessage'), array(), '', FALSE);
39 $notEmptyValidator->expects($this->once())->method('addError');
40 $notEmptyValidator->isValid('');
41 }
42
43 /**
44 * @test
45 */
46 public function notEmptyValidatorReturnsFalseForANullValue() {
47 $notEmptyValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\NotEmptyValidator', array('addError', 'translateErrorMessage'), array(), '', FALSE);
48 $notEmptyValidator->expects($this->once())->method('addError');
49 $notEmptyValidator->isValid(NULL);
50 }
51
52 /**
53 * @test
54 */
55 public function notEmptyValidatorCreatesTheCorrectErrorForAnEmptySubject() {
56 $notEmptyValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\NotEmptyValidator', array('addError', 'translateErrorMessage'), array(), '', FALSE);
57 // we only test for the error key, after the translation method is mocked.
58 $notEmptyValidator->expects($this->once())->method('addError')->with(NULL, 1221560718);
59 $notEmptyValidator->isValid('');
60 }
61
62 /**
63 * @test
64 */
65 public function notEmptyValidatorCreatesTheCorrectErrorForANullValue() {
66 $notEmptyValidator = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\NotEmptyValidator', array('addError', 'translateErrorMessage'), array(), '', FALSE);
67 // we only test for the error key, after the translation method is mocked.
68 $notEmptyValidator->expects($this->once())->method('addError')->with(NULL, 1221560910);
69 $notEmptyValidator->isValid(NULL);
70 }
71 }