1fbbc949be97a18dbdef5ab7c39adf8a19b00cd7
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Tests / Unit / Filter / IntegerFilterTest.php
1 <?php
2 namespace TYPO3\CMS\Form\Tests\Unit\Filter;
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 /**
18 * Test case
19 */
20 class IntegerFilterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
21 {
22 /**
23 * @var \TYPO3\CMS\Form\Domain\Filter\IntegerFilter
24 */
25 protected $subject;
26
27 protected function setUp()
28 {
29 $this->subject = new \TYPO3\CMS\Form\Domain\Filter\IntegerFilter();
30 }
31
32 public function dataProvider()
33 {
34 return array(
35 '"1" -> 1' => array('1', 1),
36 '1 -> 1' => array(1, 1),
37 '1.1 -> 1' => array(1.1, 1),
38 '1+E42 -> 1' => array(1+'E42', 1),
39 'a -> 0' => array('a', 0),
40 'a42 -> 0' => array('a42', 0),
41 '-100.00 -> -100' => array(-100.00, -100),
42 );
43 }
44
45 /**
46 * @test
47 * @dataProvider dataProvider
48 */
49 public function filterForVariousInputReturnsInputCastedToInteger($input, $expected)
50 {
51 $this->assertSame(
52 $expected,
53 $this->subject->filter($input)
54 );
55 }
56 }