‪TYPO3CMS  10.4
NumberRangeValidatorTest.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 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪NumberRangeValidatorTest extends UnitTestCase
25 {
29  protected ‪$validatorClassName = NumberRangeValidator::class;
30 
35  {
36  $options = ['minimum' => 0, 'maximum' => 1000];
37  ‪$validator = $this->getMockBuilder($this->validatorClassName)
38  ->setMethods(['dummy'])
39  ->setConstructorArgs([$options])
40  ->getMock();
41  self::assertFalse(‪$validator->validate(10.5)->hasErrors());
42  }
43 
48  {
49  $options = ['minimum' => 0, 'maximum' => 1000];
50  ‪$validator = $this->getMockBuilder($this->validatorClassName)
51  ->setMethods(['translateErrorMessage'])
52  ->setConstructorArgs([$options])
53  ->getMock();
54  self::assertTrue(‪$validator->validate(1000.1)->hasErrors());
55  }
56 
61  {
62  $options = ['minimum' => 1000, 'maximum' => 0];
63  ‪$validator = $this->getMockBuilder($this->validatorClassName)
64  ->setMethods(['dummy'])
65  ->setConstructorArgs([$options])
66  ->getMock();
67  self::assertFalse(‪$validator->validate(100)->hasErrors());
68  }
69 
74  {
75  $options = ['minimum' => 0, 'maximum' => 1000];
76  ‪$validator = $this->getMockBuilder($this->validatorClassName)
77  ->setMethods(['translateErrorMessage'])
78  ->setConstructorArgs([$options])
79  ->getMock();
80  self::assertTrue(‪$validator->validate('not a number')->hasErrors());
81  }
82 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest\numberRangeValidatorReturnsErrorForAString
‪numberRangeValidatorReturnsErrorForAString()
Definition: NumberRangeValidatorTest.php:72
‪TYPO3\CMS\Extbase\Validation\Validator\NumberRangeValidator
Definition: NumberRangeValidator.php:22
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest
Definition: NumberRangeValidatorTest.php:25
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest\$validatorClassName
‪string $validatorClassName
Definition: NumberRangeValidatorTest.php:28
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:218
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest\numberRangeValidatorReturnsNoErrorForANumberInReversedRange
‪numberRangeValidatorReturnsNoErrorForANumberInReversedRange()
Definition: NumberRangeValidatorTest.php:59
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest\numberRangeValidatorReturnsNoErrorForASimpleIntegerInRange
‪numberRangeValidatorReturnsNoErrorForASimpleIntegerInRange()
Definition: NumberRangeValidatorTest.php:33
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:16
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest\numberRangeValidatorReturnsErrorForANumberOutOfRange
‪numberRangeValidatorReturnsErrorForANumberOutOfRange()
Definition: NumberRangeValidatorTest.php:46