‪TYPO3CMS  9.5
NumberRangeValidatorTest.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 
17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
18 
22 class ‪NumberRangeValidatorTest extends UnitTestCase
23 {
27  protected ‪$validatorClassName = \TYPO3\CMS\Extbase\Validation\Validator\NumberRangeValidator::class;
28 
33  {
34  $options = ['minimum' => 0, 'maximum' => 1000];
35  ‪$validator = $this->getMockBuilder($this->validatorClassName)
36  ->setMethods(['dummy'])
37  ->setConstructorArgs([$options])
38  ->getMock();
39  $this->assertFalse(‪$validator->validate(10.5)->hasErrors());
40  }
41 
46  {
47  $options = ['minimum' => 0, 'maximum' => 1000];
48  ‪$validator = $this->getMockBuilder($this->validatorClassName)
49  ->setMethods(['translateErrorMessage'])
50  ->setConstructorArgs([$options])
51  ->getMock();
52  $this->assertTrue(‪$validator->validate(1000.1)->hasErrors());
53  }
54 
59  {
60  $options = ['minimum' => 1000, 'maximum' => 0];
61  ‪$validator = $this->getMockBuilder($this->validatorClassName)
62  ->setMethods(['dummy'])
63  ->setConstructorArgs([$options])
64  ->getMock();
65  $this->assertFalse(‪$validator->validate(100)->hasErrors());
66  }
67 
72  {
73  $options = ['minimum' => 0, 'maximum' => 1000];
74  ‪$validator = $this->getMockBuilder($this->validatorClassName)
75  ->setMethods(['translateErrorMessage'])
76  ->setConstructorArgs([$options])
77  ->getMock();
78  $this->assertTrue(‪$validator->validate('not a number')->hasErrors());
79  }
80 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest\numberRangeValidatorReturnsErrorForAString
‪numberRangeValidatorReturnsErrorForAString()
Definition: NumberRangeValidatorTest.php:70
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest
Definition: NumberRangeValidatorTest.php:23
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest\$validatorClassName
‪string $validatorClassName
Definition: NumberRangeValidatorTest.php:26
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:218
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest\numberRangeValidatorReturnsNoErrorForANumberInReversedRange
‪numberRangeValidatorReturnsNoErrorForANumberInReversedRange()
Definition: NumberRangeValidatorTest.php:57
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest\numberRangeValidatorReturnsNoErrorForASimpleIntegerInRange
‪numberRangeValidatorReturnsNoErrorForASimpleIntegerInRange()
Definition: NumberRangeValidatorTest.php:31
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:2
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest\numberRangeValidatorReturnsErrorForANumberOutOfRange
‪numberRangeValidatorReturnsErrorForANumberOutOfRange()
Definition: NumberRangeValidatorTest.php:44