File tree Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 12
12
namespace Symfony \Component \Config \Definition \Builder ;
13
13
14
14
use Symfony \Component \Config \Definition \BooleanNode ;
15
+ use Symfony \Component \Config \Definition \Exception \InvalidDefinitionException ;
15
16
16
17
/**
17
18
* This class provides a fluent interface for defining a node.
@@ -39,4 +40,14 @@ protected function instantiateNode()
39
40
{
40
41
return new BooleanNode ($ this ->name , $ this ->parent );
41
42
}
43
+
44
+ /**
45
+ * {@inheritdoc}
46
+ *
47
+ * @throws InvalidDefinitionException
48
+ */
49
+ public function cannotBeEmpty ()
50
+ {
51
+ throw new InvalidDefinitionException ('->cannotBeEmpty() is not applicable to BooleanNodeDefinition. ' );
52
+ }
42
53
}
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Config \Definition \Builder ;
13
13
14
+ use Symfony \Component \Config \Definition \Exception \InvalidDefinitionException ;
15
+
14
16
/**
15
17
* Abstract class that contains common code of integer and float node definitions.
16
18
*
@@ -58,4 +60,14 @@ public function min($min)
58
60
59
61
return $ this ;
60
62
}
63
+
64
+ /**
65
+ * {@inheritdoc}
66
+ *
67
+ * @throws InvalidDefinitionException
68
+ */
69
+ public function cannotBeEmpty ()
70
+ {
71
+ throw new InvalidDefinitionException ('->cannotBeEmpty() is not applicable to NumericNodeDefinition. ' );
72
+ }
61
73
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <[email protected] >
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 \Builder ;
13
+
14
+ use Symfony \Component \Config \Definition \Builder \BooleanNodeDefinition ;
15
+
16
+ class BooleanNodeDefinitionTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * @expectedException Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
20
+ * @expectedExceptionMessage ->cannotBeEmpty() is not applicable to BooleanNodeDefinition.
21
+ */
22
+ public function testCannotBeEmptyThrowsAnException ()
23
+ {
24
+ $ def = new BooleanNodeDefinition ('foo ' );
25
+ $ def ->cannotBeEmpty ();
26
+ }
27
+ }
Original file line number Diff line number Diff line change @@ -90,4 +90,14 @@ public function testFloatValidMinMaxAssertion()
90
90
$ node = $ def ->min (3.0 )->max (7e2 )->getNode ();
91
91
$ this ->assertEquals (4.5 , $ node ->finalize (4.5 ));
92
92
}
93
+
94
+ /**
95
+ * @expectedException Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
96
+ * @expectedExceptionMessage ->cannotBeEmpty() is not applicable to NumericNodeDefinition.
97
+ */
98
+ public function testCannotBeEmptyThrowsAnException ()
99
+ {
100
+ $ def = new NumericNodeDefinition ('foo ' );
101
+ $ def ->cannotBeEmpty ();
102
+ }
93
103
}
You can’t perform that action at this time.
0 commit comments