11
11
12
12
namespace Symfony \Bundle \MonologBundle \Tests \DependencyInjection ;
13
13
14
+ use InvalidArgumentException ;
14
15
use Monolog \Logger ;
15
16
use Symfony \Bundle \MonologBundle \DependencyInjection \MonologExtension ;
16
17
use Symfony \Bundle \MonologBundle \DependencyInjection \Compiler \LoggerChannelPass ;
@@ -537,15 +538,16 @@ public function testFingersCrossedHandlerWhenExcludedHttpCodesAreSpecified()
537
538
* @param string $handlerType
538
539
* @dataProvider v2RemovedDataProvider
539
540
*/
540
- public function testMonologV2RemovedOnV1 ($ handlerType )
541
+ public function testV2Removed ($ handlerType )
541
542
{
542
- if (Logger::API === 2 ) {
543
- $ this ->doesNotPerformAssertions ( );
543
+ if (Logger::API === 1 ) {
544
+ $ this ->markTestSkipped ( ' Not valid for V1 ' );
544
545
545
546
return ;
546
547
}
547
548
548
- $ this ->expectException (InvalidConfigurationException::class);
549
+ $ this ->expectException (InvalidArgumentException::class);
550
+ $ this ->expectExceptionMessage (sprintf ('"%s" was removed in MonoLog v2. ' , $ handlerType ));
549
551
550
552
$ container = new ContainerBuilder ();
551
553
$ loader = new MonologExtension ();
@@ -562,6 +564,37 @@ public function v2RemovedDataProvider()
562
564
];
563
565
}
564
566
567
+ /**
568
+ * @param string $handlerType
569
+ * @dataProvider v1AddedDataProvider
570
+ */
571
+ public function testV2AddedOnV1 ($ handlerType )
572
+ {
573
+ if (Logger::API === 2 ) {
574
+ $ this ->markTestSkipped ('Not valid for V2 ' );
575
+
576
+ return ;
577
+ }
578
+
579
+ $ this ->expectException (InvalidArgumentException::class);
580
+ $ this ->expectExceptionMessage (
581
+ sprintf ('"%s" was added in MonoLog v2, please upgrade if you wish to use. ' , $ handlerType )
582
+ );
583
+
584
+ $ container = new ContainerBuilder ();
585
+ $ loader = new MonologExtension ();
586
+
587
+ $ loader ->load ([['handlers ' => ['main ' => ['type ' => $ handlerType ]]]], $ container );
588
+ }
589
+
590
+ public function v1AddedDataProvider ()
591
+ {
592
+ return [
593
+ ['fallbackgroup ' ],
594
+ ];
595
+ }
596
+
597
+
565
598
protected function getContainer (array $ config = [], array $ thirdPartyDefinitions = [])
566
599
{
567
600
$ container = new ContainerBuilder ();
0 commit comments