@@ -1048,15 +1048,21 @@ public function testMongoDB()
10481048 $ this ->assertTrue ($ container ->hasDefinition ('monolog.handler.mongodb_with_uri ' ));
10491049 $ this ->assertTrue ($ container ->hasDefinition ('monolog.handler.mongodb_with_uri_and_default_args ' ));
10501050
1051+ // A MongoDBFormatter will be applied to each handler by default
1052+ $ formatter = new Definition ('Monolog\Formatter\MongoDBFormatter ' );
1053+ $ formatter ->setPublic (false );
1054+
10511055 // MongoDB handler should receive the mongodb.client as first argument
10521056 $ handler = $ container ->getDefinition ('monolog.handler.mongodb_with_id ' );
10531057 $ this ->assertDICDefinitionClass ($ handler , MongoDBHandler::class);
10541058 $ this ->assertDICConstructorArguments ($ handler , [new Reference ('mongodb.client ' ), 'monolog ' , 'logs ' , 'DEBUG ' , true ]);
1059+ $ this ->assertDICDefinitionMethodCallAt (1 , $ handler , 'setFormatter ' , [$ formatter ]);
10551060
10561061 // MongoDB handler should receive the mongodb.client as first argument
10571062 $ handler = $ container ->getDefinition ('monolog.handler.mongodb_with_string_id ' );
10581063 $ this ->assertDICDefinitionClass ($ handler , MongoDBHandler::class);
10591064 $ this ->assertDICConstructorArguments ($ handler , [new Reference ('mongodb.client ' ), 'monolog ' , 'logs ' , 'DEBUG ' , true ]);
1065+ $ this ->assertDICDefinitionMethodCallAt (1 , $ handler , 'setFormatter ' , [$ formatter ]);
10601066
10611067 // MongoDB handler with arguments
10621068 $ handler = $ container ->getDefinition ('monolog.handler.mongodb_with_uri ' );
@@ -1065,6 +1071,7 @@ public function testMongoDB()
10651071 $ this ->assertDICDefinitionClass ($ client , 'MongoDB\Client ' );
10661072 $ this ->assertDICConstructorArguments ($ client , ['mongodb://localhost:27018 ' , ['appname ' => 'monolog-bundle ' , 'username ' => 'username ' , 'password ' => 'password ' ]]);
10671073 $ this ->assertDICConstructorArguments ($ handler , [$ client , 'db ' , 'coll ' , 'DEBUG ' , true ]);
1074+ $ this ->assertDICDefinitionMethodCallAt (1 , $ handler , 'setFormatter ' , [$ formatter ]);
10681075
10691076 // MongoDB handler with host and default arguments
10701077 $ handler = $ container ->getDefinition ('monolog.handler.mongodb_with_uri_and_default_args ' );
@@ -1073,6 +1080,7 @@ public function testMongoDB()
10731080 $ this ->assertDICDefinitionClass ($ client , 'MongoDB\Client ' );
10741081 $ this ->assertDICConstructorArguments ($ client , ['mongodb://localhost:27018 ' , ['appname ' => 'monolog-bundle ' ]]);
10751082 $ this ->assertDICConstructorArguments ($ handler , [$ client , 'monolog ' , 'logs ' , 'DEBUG ' , true ]);
1083+ $ this ->assertDICDefinitionMethodCallAt (1 , $ handler , 'setFormatter ' , [$ formatter ]);
10761084 }
10771085
10781086 protected function getContainer (array $ config = [], array $ thirdPartyDefinitions = []): ContainerBuilder
0 commit comments