@@ -501,7 +501,7 @@ public function testLazyDeprecationFailsIfInvalidDeprecationMessageType()
501
501
502
502
/**
503
503
* @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
504
- * @expectedExceptionMessage The options "bar ", "foo " have a cyclic dependency.
504
+ * @expectedExceptionMessage The options "foo ", "bar " have a cyclic dependency.
505
505
*/
506
506
public function testFailsIfCyclicDependencyBetweenDeprecation ()
507
507
{
@@ -538,10 +538,15 @@ public function testIsNotDeprecatedIfEmptyString()
538
538
/**
539
539
* @dataProvider provideDeprecationData
540
540
*/
541
- public function testDeprecationMessages (\Closure $ configureOptions , array $ options , ?array $ expectedError )
541
+ public function testDeprecationMessages (\Closure $ configureOptions , array $ options , ?array $ expectedError, int $ expectedCount )
542
542
{
543
+ $ count = 0 ;
543
544
error_clear_last ();
544
- set_error_handler (function () { return false ; });
545
+ set_error_handler (function () use (&$ count ) {
546
+ ++$ count ;
547
+
548
+ return false ;
549
+ });
545
550
$ e = error_reporting (0 );
546
551
547
552
$ configureOptions ($ this ->resolver );
@@ -554,6 +559,7 @@ public function testDeprecationMessages(\Closure $configureOptions, array $optio
554
559
unset($ lastError ['file ' ], $ lastError ['line ' ]);
555
560
556
561
$ this ->assertSame ($ expectedError , $ lastError );
562
+ $ this ->assertSame ($ expectedCount , $ count );
557
563
}
558
564
559
565
public function provideDeprecationData ()
@@ -570,6 +576,7 @@ function (OptionsResolver $resolver) {
570
576
'type ' => E_USER_DEPRECATED ,
571
577
'message ' => 'The option "foo" is deprecated. ' ,
572
578
),
579
+ 1 ,
573
580
);
574
581
575
582
yield 'It deprecates an option with custom message ' => array (
@@ -587,6 +594,7 @@ function (OptionsResolver $resolver) {
587
594
'type ' => E_USER_DEPRECATED ,
588
595
'message ' => 'The option "foo" is deprecated, use "bar" option instead. ' ,
589
596
),
597
+ 2 ,
590
598
);
591
599
592
600
yield 'It does not deprecates a missing option with default value ' => array (
@@ -598,6 +606,7 @@ function (OptionsResolver $resolver) {
598
606
},
599
607
array (),
600
608
null ,
609
+ 0 ,
601
610
);
602
611
603
612
yield 'It deprecates an option evaluated in another definition ' => array (
@@ -617,6 +626,7 @@ function (OptionsResolver $resolver) {
617
626
'type ' => E_USER_DEPRECATED ,
618
627
'message ' => 'The option "foo" is deprecated. ' ,
619
628
),
629
+ 1 ,
620
630
);
621
631
622
632
yield 'It deprecates allowed type and value ' => array (
@@ -638,6 +648,7 @@ function (OptionsResolver $resolver) {
638
648
'type ' => E_USER_DEPRECATED ,
639
649
'message ' => 'Passing an instance of "stdClass" to option "foo" is deprecated, pass its FQCN instead. ' ,
640
650
),
651
+ 1 ,
641
652
);
642
653
643
654
yield 'It ignores deprecation for missing option without default value ' => array (
@@ -649,6 +660,7 @@ function (OptionsResolver $resolver) {
649
660
},
650
661
array ('bar ' => 'baz ' ),
651
662
null ,
663
+ 0 ,
652
664
);
653
665
654
666
yield 'It ignores deprecation if closure returns an empty string ' => array (
@@ -662,6 +674,7 @@ function (OptionsResolver $resolver) {
662
674
},
663
675
array ('foo ' => Bar::class),
664
676
null ,
677
+ 0 ,
665
678
);
666
679
667
680
yield 'It deprecates value depending on other option value ' => array (
@@ -683,6 +696,7 @@ function (OptionsResolver $resolver) {
683
696
'type ' => E_USER_DEPRECATED ,
684
697
'message ' => 'Using the "date_format" option when the "widget" option is set to "single_text" is deprecated. ' ,
685
698
),
699
+ 1 ,
686
700
);
687
701
}
688
702
0 commit comments