@@ -504,7 +504,19 @@ public function testFailIfSetAllowedTypesFromLazyOption()
504
504
*/
505
505
public function testResolveFailsIfInvalidType ()
506
506
{
507
- $ this ->resolver ->setDefault ('foo ' , 42 );
507
+ $ this ->resolver ->setDefined ('foo ' );
508
+ $ this ->resolver ->setAllowedTypes ('foo ' , 'string ' );
509
+
510
+ $ this ->resolver ->resolve (array ('foo ' => 42 ));
511
+ }
512
+
513
+ /**
514
+ * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
515
+ * @expectedExceptionMessage The option "foo" with value null is expected to be of type "string", but is of type "NULL".
516
+ */
517
+ public function testResolveFailsIfInvalidTypeIsNull ()
518
+ {
519
+ $ this ->resolver ->setDefault ('foo ' , null );
508
520
$ this ->resolver ->setAllowedTypes ('foo ' , 'string ' );
509
521
510
522
$ this ->resolver ->resolve ();
@@ -675,7 +687,19 @@ public function testFailIfSetAllowedValuesFromLazyOption()
675
687
*/
676
688
public function testResolveFailsIfInvalidValue ()
677
689
{
678
- $ this ->resolver ->setDefault ('foo ' , 42 );
690
+ $ this ->resolver ->setDefined ('foo ' );
691
+ $ this ->resolver ->setAllowedValues ('foo ' , 'bar ' );
692
+
693
+ $ this ->resolver ->resolve (array ('foo ' => 42 ));
694
+ }
695
+
696
+ /**
697
+ * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
698
+ * @expectedExceptionMessage The option "foo" with value null is invalid. Accepted values are: "bar".
699
+ */
700
+ public function testResolveFailsIfInvalidValueIsNull ()
701
+ {
702
+ $ this ->resolver ->setDefault ('foo ' , null );
679
703
$ this ->resolver ->setAllowedValues ('foo ' , 'bar ' );
680
704
681
705
$ this ->resolver ->resolve ();
0 commit comments