21
21
use Symfony \Bundle \MonologBundle \DependencyInjection \MonologExtension ;
22
22
use Symfony \Bundle \MonologBundle \DependencyInjection \Compiler \LoggerChannelPass ;
23
23
use Symfony \Bundle \MonologBundle \Tests \DependencyInjection \Fixtures \AsMonologProcessor \FooProcessor ;
24
+ use Symfony \Bundle \MonologBundle \Tests \DependencyInjection \Fixtures \AsMonologProcessor \FooProcessorWithPriority ;
24
25
use Symfony \Bundle \MonologBundle \Tests \DependencyInjection \Fixtures \AsMonologProcessor \RedeclareMethodProcessor ;
25
26
use Symfony \Component \DependencyInjection \ContainerBuilder ;
26
27
use Symfony \Component \DependencyInjection \Definition ;
@@ -826,8 +827,8 @@ public function testAsMonologProcessorAutoconfigurationRedeclareMethod(): void
826
827
*/
827
828
public function testAsMonologProcessorAutoconfiguration (): void
828
829
{
829
- if (!\class_exists (AsMonologProcessor::class, true )) {
830
- $ this ->markTestSkipped ('Monolog >= 2.3.6 is needed. ' );
830
+ if (!\class_exists (AsMonologProcessor::class, true ) || \property_exists (AsMonologProcessor::class, ' priority ' ) ) {
831
+ $ this ->markTestSkipped ('Monolog >= 2.3.6 and < 3.4.0 is needed. ' );
831
832
}
832
833
833
834
$ container = $ this ->getContainer ([], [
@@ -848,6 +849,35 @@ public function testAsMonologProcessorAutoconfiguration(): void
848
849
], $ container ->getDefinition (FooProcessor::class)->getTag ('monolog.processor ' ));
849
850
}
850
851
852
+ /**
853
+ * @requires PHP 8.0
854
+ */
855
+ public function testAsMonologProcessorAutoconfigurationWithPriority (): void
856
+ {
857
+ if (!\class_exists (AsMonologProcessor::class, true ) || !\property_exists (AsMonologProcessor::class, 'priority ' )) {
858
+ $ this ->markTestSkipped ('Monolog >= 3.4.0 is needed. ' );
859
+ }
860
+
861
+ $ container = $ this ->getContainer ([], [
862
+ FooProcessorWithPriority::class => (new Definition (FooProcessorWithPriority::class))->setAutoconfigured (true ),
863
+ ]);
864
+
865
+ $ this ->assertSame ([
866
+ [
867
+ 'channel ' => null ,
868
+ 'handler ' => 'foo_handler ' ,
869
+ 'method ' => null ,
870
+ 'priority ' => null ,
871
+ ],
872
+ [
873
+ 'channel ' => 'ccc_channel ' ,
874
+ 'handler ' => null ,
875
+ 'method ' => '__invoke ' ,
876
+ 'priority ' => 10 ,
877
+ ],
878
+ ], $ container ->getDefinition (FooProcessorWithPriority::class)->getTag ('monolog.processor ' ));
879
+ }
880
+
851
881
protected function getContainer (array $ config = [], array $ thirdPartyDefinitions = [])
852
882
{
853
883
$ container = new ContainerBuilder (new EnvPlaceholderParameterBag ());
0 commit comments