1111
1212namespace Symfony \Bundle \MonologBundle \Tests \DependencyInjection ;
1313
14+ use InvalidArgumentException ;
1415use Monolog \Logger ;
1516use Symfony \Bundle \MonologBundle \DependencyInjection \MonologExtension ;
1617use Symfony \Bundle \MonologBundle \DependencyInjection \Compiler \LoggerChannelPass ;
@@ -537,15 +538,16 @@ public function testFingersCrossedHandlerWhenExcludedHttpCodesAreSpecified()
537538 * @param string $handlerType
538539 * @dataProvider v2RemovedDataProvider
539540 */
540- public function testMonologV2RemovedOnV1 ($ handlerType )
541+ public function testV2Removed ($ handlerType )
541542 {
542- if (Logger::API === 2 ) {
543- $ this ->doesNotPerformAssertions ( );
543+ if (Logger::API === 1 ) {
544+ $ this ->markTestSkipped ( ' Not valid for V1 ' );
544545
545546 return ;
546547 }
547548
548- $ this ->expectException (InvalidConfigurationException::class);
549+ $ this ->expectException (InvalidArgumentException::class);
550+ $ this ->expectExceptionMessage (sprintf ('"%s" was removed in MonoLog v2. ' , $ handlerType ));
549551
550552 $ container = new ContainerBuilder ();
551553 $ loader = new MonologExtension ();
@@ -562,6 +564,37 @@ public function v2RemovedDataProvider()
562564 ];
563565 }
564566
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+
565598 protected function getContainer (array $ config = [], array $ thirdPartyDefinitions = [])
566599 {
567600 $ container = new ContainerBuilder ();
0 commit comments