Yaffs site version 1.1
[yaffs-website] / vendor / symfony / config / Tests / Definition / BooleanNodeTest.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\BooleanNode;
16
17 class BooleanNodeTest extends TestCase
18 {
19     /**
20      * @dataProvider getValidValues
21      */
22     public function testNormalize($value)
23     {
24         $node = new BooleanNode('test');
25         $this->assertSame($value, $node->normalize($value));
26     }
27
28     /**
29      * @dataProvider getValidValues
30      *
31      * @param bool $value
32      */
33     public function testValidNonEmptyValues($value)
34     {
35         $node = new BooleanNode('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(false),
45             array(true),
46         );
47     }
48
49     /**
50      * @dataProvider getInvalidValues
51      * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException
52      */
53     public function testNormalizeThrowsExceptionOnInvalidValues($value)
54     {
55         $node = new BooleanNode('test');
56         $node->normalize($value);
57     }
58
59     public function getInvalidValues()
60     {
61         return array(
62             array(null),
63             array(''),
64             array('foo'),
65             array(0),
66             array(1),
67             array(0.0),
68             array(0.1),
69             array(array()),
70             array(array('foo' => 'bar')),
71             array(new \stdClass()),
72         );
73     }
74 }