File tree Expand file tree Collapse file tree 4 files changed +60
-0
lines changed
src/Symfony/Component/Config Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 1212namespace Symfony \Component \Config \Definition \Builder ;
1313
1414use Symfony \Component \Config \Definition \BooleanNode ;
15+ use Symfony \Component \Config \Definition \Exception \InvalidDefinitionException ;
1516
1617/**
1718 * This class provides a fluent interface for defining a node.
@@ -39,4 +40,14 @@ protected function instantiateNode()
3940 {
4041 return new BooleanNode ($ this ->name , $ this ->parent );
4142 }
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+ }
4253}
Original file line number Diff line number Diff line change 1111
1212namespace Symfony \Component \Config \Definition \Builder ;
1313
14+ use Symfony \Component \Config \Definition \Exception \InvalidDefinitionException ;
15+
1416/**
1517 * Abstract class that contains common code of integer and float node definitions.
1618 *
@@ -58,4 +60,14 @@ public function min($min)
5860
5961 return $ this ;
6062 }
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+ }
6173}
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 <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 \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()
9090 $ node = $ def ->min (3.0 )->max (7e2 )->getNode ();
9191 $ this ->assertEquals (4.5 , $ node ->finalize (4.5 ));
9292 }
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+ }
93103}
You can’t perform that action at this time.
0 commit comments