File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,7 @@ public function __construct(array $config = [])
196196 'prompt ' => '' ,
197197 'openid.realm ' => '' ,
198198 'include_granted_scopes ' => null ,
199+ 'logger ' => null ,
199200 'login_hint ' => '' ,
200201 'request_visible_actions ' => '' ,
201202 'access_type ' => 'online ' ,
@@ -242,6 +243,11 @@ public function __construct(array $config = [])
242243 $ this ->setCache ($ this ->config ['cache ' ]);
243244 unset($ this ->config ['cache ' ]);
244245 }
246+
247+ if (!is_null ($ this ->config ['logger ' ])) {
248+ $ this ->setLogger ($ this ->config ['logger ' ]);
249+ unset($ this ->config ['logger ' ]);
250+ }
245251 }
246252
247253 /**
Original file line number Diff line number Diff line change @@ -268,6 +268,16 @@ public function testDefaultLoggerAppEngine()
268268 $ this ->assertInstanceOf ('Monolog\Handler\SyslogHandler ' , $ handler );
269269 }
270270
271+ public function testLoggerFromConstructor ()
272+ {
273+ $ logger1 = new \Monolog \Logger ('unit-test ' );
274+ $ client = new Client (['logger ' => $ logger1 ]);
275+ $ logger2 = $ client ->getLogger ();
276+ $ this ->assertInstanceOf ('Monolog\Logger ' , $ logger2 );
277+ $ this ->assertEquals ('unit-test ' , $ logger2 ->getName ());
278+ $ this ->assertSame ($ logger1 , $ logger2 );
279+ }
280+
271281 public function testSettersGetters ()
272282 {
273283 $ client = new Client ();
@@ -279,6 +289,7 @@ public function testSettersGetters()
279289
280290 $ client ->setRedirectUri ('localhost ' );
281291 $ client ->setConfig ('application_name ' , 'me ' );
292+ $ client ->setLogger (new \Monolog \Logger ('test ' ));
282293
283294 $ cache = $ this ->prophesize (CacheItemPoolInterface::class);
284295 $ client ->setCache ($ cache ->reveal ());
You can’t perform that action at this time.
0 commit comments