Yaffs site version 1.1
[yaffs-website] / vendor / symfony / config / Tests / Definition / IntegerNodeTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Config\Tests\Definition;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Definition\IntegerNode;
16
17 class IntegerNodeTest extends TestCase
18 {
19     /**
20      * @dataProvider getValidValues
21      */
22     public function testNormalize($value)
23     {
24         $node = new IntegerNode('test');
25         $this->assertSame($value, $node->normalize($value));
26     }
27
28     /**
29      * @dataProvider getValidValues
30      *
31      * @param int $value
32      */
33     public function testValidNonEmptyValues($value)
34     {
35         $node = new IntegerNode('test');
36         $node->setAllowEmptyValue(false);
37
38         $this->assertSame($value, $node->finalize($value));
39     }
40
41     public function getValidValues()
42     {
43         return array(
44             array(1798),
45             array(-678),
46             array(0),
47         );
48     }
49
50     /**
51      * @dataProvider getInvalidValues
52      * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException
53      */
54     public function testNormalizeThrowsExceptionOnInvalidValues($value)
55     {
56         $node = new IntegerNode('test');
57         $node->normalize($value);
58     }
59
60     public function getInvalidValues()
61     {
62         return array(
63             array(null),
64             array(''),
65             array('foo'),
66             array(true),
67             array(false),
68             array(0.0),
69             array(0.1),
70             array(array()),
71             array(array('foo' => 'bar')),
72             array(new \stdClass()),
73         );
74     }
75 }