‪TYPO3CMS  9.5
IntegerValidatorTest.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 ‪$validatorClassName = \TYPO3\CMS\Extbase\Validation\Validator\IntegerValidator::class;
26 
27  public function ‪setup()
28  {
29  $this->validator = $this->getMockBuilder($this->validatorClassName)
30  ->setMethods(['translateErrorMessage'])
31  ->getMock();
32  }
33 
39  public function ‪validIntegers()
40  {
41  return [
42  [1029437],
43  ['12345'],
44  ['+12345'],
45  ['-12345']
46  ];
47  }
48 
55  {
56  $this->assertFalse($this->validator->validate($integer)->hasErrors());
57  }
58 
64  public function ‪invalidIntegers()
65  {
66  return [
67  ['not a number'],
68  [3.1415],
69  ['12345.987']
70  ];
71  }
72 
78  public function ‪integerValidatorReturnsErrorForAnInvalidInteger($invalidInteger)
79  {
80  $this->assertTrue($this->validator->validate($invalidInteger)->hasErrors());
81  }
82 
87  {
88  $this->assertEquals(1, count($this->validator->validate('not a number')->getErrors()));
89  }
90 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\IntegerValidatorTest\integerValidatorReturnsNoErrorsForAValidInteger
‪integerValidatorReturnsNoErrorsForAValidInteger($integer)
Definition: IntegerValidatorTest.php:53
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\IntegerValidatorTest\invalidIntegers
‪array invalidIntegers()
Definition: IntegerValidatorTest.php:63
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\IntegerValidatorTest
Definition: IntegerValidatorTest.php:21
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\IntegerValidatorTest\setup
‪setup()
Definition: IntegerValidatorTest.php:26
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\IntegerValidatorTest\integerValidatorCreatesTheCorrectErrorForAnInvalidSubject
‪integerValidatorCreatesTheCorrectErrorForAnInvalidSubject()
Definition: IntegerValidatorTest.php:85
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\IntegerValidatorTest\validIntegers
‪array validIntegers()
Definition: IntegerValidatorTest.php:38
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\IntegerValidatorTest\$validatorClassName
‪string $validatorClassName
Definition: IntegerValidatorTest.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\IntegerValidatorTest\integerValidatorReturnsErrorForAnInvalidInteger
‪integerValidatorReturnsErrorForAnInvalidInteger($invalidInteger)
Definition: IntegerValidatorTest.php:77
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:2
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\AbstractValidatorTestcase
Definition: AbstractValidatorTestcase.php:24