‪TYPO3CMS  9.5
FloatValidatorTest.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\FloatValidator::class;
26 
27  public function ‪setup()
28  {
29  $this->validator = $this->getMockBuilder($this->validatorClassName)
30  ->setMethods(['translateErrorMessage'])
31  ->getMock();
32  }
33 
39  public function ‪validFloats()
40  {
41  return [
42  [1029437.234726],
43  ['123.45'],
44  ['+123.45'],
45  ['-123.45'],
46  ['123.45e3'],
47  [123450.0]
48  ];
49  }
50 
57  {
58  $this->assertFalse($this->validator->validate($float)->hasErrors());
59  }
60 
66  public function ‪invalidFloats()
67  {
68  return [
69  [1029437],
70  ['1029437'],
71  ['not a number']
72  ];
73  }
74 
81  {
82  $this->assertTrue($this->validator->validate($float)->hasErrors());
83  }
84 
89  {
90  $this->assertEquals(1, count($this->validator->validate(123456)->getErrors()));
91  }
92 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\FloatValidatorTest\$validatorClassName
‪string $validatorClassName
Definition: FloatValidatorTest.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\FloatValidatorTest\floatValidatorCreatesTheCorrectErrorForAnInvalidSubject
‪floatValidatorCreatesTheCorrectErrorForAnInvalidSubject()
Definition: FloatValidatorTest.php:87
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\FloatValidatorTest
Definition: FloatValidatorTest.php:21
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\FloatValidatorTest\floatValidatorReturnsErrorForAnInvalidFloat
‪floatValidatorReturnsErrorForAnInvalidFloat($float)
Definition: FloatValidatorTest.php:79
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\FloatValidatorTest\floatValidatorReturnsNoErrorsForAValidFloat
‪floatValidatorReturnsNoErrorsForAValidFloat($float)
Definition: FloatValidatorTest.php:55
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\FloatValidatorTest\setup
‪setup()
Definition: FloatValidatorTest.php:26
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\FloatValidatorTest\invalidFloats
‪array invalidFloats()
Definition: FloatValidatorTest.php:65
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:2
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\AbstractValidatorTestcase
Definition: AbstractValidatorTestcase.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\FloatValidatorTest\validFloats
‪array validFloats()
Definition: FloatValidatorTest.php:38