|
11 | 11 |
|
12 | 12 | namespace Symfony\Bundle\MonologBundle\Tests\DependencyInjection;
|
13 | 13 |
|
| 14 | +use InvalidArgumentException; |
| 15 | +use Monolog\Logger; |
14 | 16 | use Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension;
|
15 | 17 | use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
|
16 | 18 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
@@ -532,6 +534,67 @@ public function testFingersCrossedHandlerWhenExcludedHttpCodesAreSpecified()
|
532 | 534 | $this->assertDICConstructorArguments($handler, [new Reference('monolog.handler.nested'), new Reference('monolog.handler.main.http_code_strategy'), 0, true, true, null]);
|
533 | 535 | }
|
534 | 536 |
|
| 537 | + /** |
| 538 | + * @param string $handlerType |
| 539 | + * @dataProvider v2RemovedDataProvider |
| 540 | + */ |
| 541 | + public function testV2Removed($handlerType) |
| 542 | + { |
| 543 | + if (Logger::API === 1) { |
| 544 | + $this->markTestSkipped('Not valid for V1'); |
| 545 | + |
| 546 | + return; |
| 547 | + } |
| 548 | + |
| 549 | + $this->expectException(InvalidArgumentException::class); |
| 550 | + $this->expectExceptionMessage(sprintf('"%s" was removed in Monolog v2.', $handlerType)); |
| 551 | + |
| 552 | + $container = new ContainerBuilder(); |
| 553 | + $loader = new MonologExtension(); |
| 554 | + |
| 555 | + $loader->load([['handlers' => ['main' => ['type' => $handlerType]]]], $container); |
| 556 | + } |
| 557 | + |
| 558 | + public function v2RemovedDataProvider() |
| 559 | + { |
| 560 | + return [ |
| 561 | + ['hipchat'], |
| 562 | + ['raven'], |
| 563 | + ['slackbot'], |
| 564 | + ]; |
| 565 | + } |
| 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 it.', $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 | + |
535 | 598 | protected function getContainer(array $config = [], array $thirdPartyDefinitions = [])
|
536 | 599 | {
|
537 | 600 | $container = new ContainerBuilder();
|
|
0 commit comments