Skip to content

Commit 8e6ff5d

Browse files
committed
Improve tests
1 parent 63176d9 commit 8e6ff5d

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

Tests/DependencyInjection/MonologExtensionTest.php

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\MonologBundle\Tests\DependencyInjection;
1313

14+
use InvalidArgumentException;
1415
use Monolog\Logger;
1516
use Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension;
1617
use 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

Comments
 (0)