File tree 2 files changed +16
-1
lines changed
src/Symfony/Component/Console
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -601,10 +601,15 @@ public function getUsages()
601
601
*
602
602
* @return mixed The helper value
603
603
*
604
- * @throws InvalidArgumentException if the helper is not defined
604
+ * @throws LogicException If no helperSet is defined
605
+ * @throws InvalidArgumentException If the helper is not defined
605
606
*/
606
607
public function getHelper ($ name )
607
608
{
609
+ if (null === $ this ->helperSet ) {
610
+ throw new LogicException (sprintf ('Cannot retrieve helper "%s" because there is no HelperSet defined. ' , $ name ));
611
+ }
612
+
608
613
return $ this ->helperSet ->get ($ name );
609
614
}
610
615
Original file line number Diff line number Diff line change @@ -173,6 +173,16 @@ public function testGetHelper()
173
173
$ this ->assertEquals ($ formatterHelper ->getName (), $ command ->getHelper ('formatter ' )->getName (), '->getHelper() returns the correct helper ' );
174
174
}
175
175
176
+ /**
177
+ * @expectedException \LogicException
178
+ * @expectedExceptionMessage Cannot retrieve helper "formatter" because there is no HelperSet defined.
179
+ */
180
+ public function testGetHelperWithoutHelperSet ()
181
+ {
182
+ $ command = new \TestCommand ();
183
+ $ command ->getHelper ('formatter ' );
184
+ }
185
+
176
186
public function testMergeApplicationDefinition ()
177
187
{
178
188
$ application1 = new Application ();
You can’t perform that action at this time.
0 commit comments