‪TYPO3CMS  10.4
NumberValidatorTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪NumberValidatorTest extends UnitTestCase
27 {
31  protected ‪$validatorClassName = NumberValidator::class;
32 
36  protected ‪$validator;
37 
38  public function ‪setup(): void
39  {
40  parent::setUp();
41  $this->validator = $this->getMockBuilder($this->validatorClassName)
42  ->setMethods(['translateErrorMessage'])
43  ->getMock();
44  }
45 
50  {
51  self::assertFalse($this->validator->validate(1029437)->hasErrors());
52  }
53 
58  {
59  $expectedResult = new Result();
60  // we only test for the error code, after the message translation method is mocked
61  $expectedResult->addError(new Error('', 1221563685));
62  self::assertEquals($expectedResult, $this->validator->validate('not a number'));
63  }
64 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberValidatorTest\numberValidatorReturnsTrueForASimpleInteger
‪numberValidatorReturnsTrueForASimpleInteger()
Definition: NumberValidatorTest.php:47
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberValidatorTest\numberValidatorReturnsFalseForAString
‪numberValidatorReturnsFalseForAString()
Definition: NumberValidatorTest.php:55
‪TYPO3\CMS\Extbase\Error\Result
Definition: Result.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberValidatorTest
Definition: NumberValidatorTest.php:27
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberValidatorTest\setup
‪setup()
Definition: NumberValidatorTest.php:36
‪TYPO3\CMS\Extbase\Error\Error
Definition: Error.php:25
‪TYPO3\CMS\Extbase\Validation\Error
Definition: Error.php:22
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberValidatorTest\$validatorClassName
‪string $validatorClassName
Definition: NumberValidatorTest.php:30
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:16
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberValidatorTest\$validator
‪TYPO3 CMS Extbase Validation Validator ValidatorInterface $validator
Definition: NumberValidatorTest.php:34
‪TYPO3\CMS\Extbase\Validation\Validator\NumberValidator
Definition: NumberValidator.php:22