File tree Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,11 @@ public static function addConnection(string $name): void
6868 return ;
6969 }
7070 $ driver = $ connection ->getDriver ();
71+
72+ if (!method_exists ($ driver , 'setLogger ' )) {
73+ return ;
74+ }
75+
7176 $ logger = null ;
7277 if ($ driver instanceof Driver) {
7378 $ logger = $ driver ->getLogger ();
Original file line number Diff line number Diff line change @@ -124,4 +124,21 @@ public function testSummary()
124124 $ result = $ this ->panel ->summary ();
125125 $ this ->assertMatchesRegularExpression ('/\d+ \\/ \d+(\.\d+)? ms/ ' , $ result );
126126 }
127+
128+ /**
129+ * Testing a simple connection (no set/getLogger on driver).
130+ *
131+ * @return void
132+ */
133+ public function testWithSimpleConnection ()
134+ {
135+ ConnectionManager::setConfig ('simple ' , [
136+ 'className ' => 'DebugKit\TestApp\Stub\SimpleConnectionStub ' ,
137+ ]);
138+
139+ $ this ->panel ->addConnection ('simple ' ); // should not throw an error
140+ $ this ->assertTrue (true );
141+
142+ ConnectionManager::drop ('simple ' );
143+ }
127144}
Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types=1 );
3+
4+ namespace DebugKit \TestApp \Stub ;
5+
6+ use Cake \Cache \Cache ;
7+ use Cake \Datasource \ConnectionInterface ;
8+ use Psr \SimpleCache \CacheInterface ;
9+ use stdClass ;
10+
11+ class SimpleConnectionStub implements ConnectionInterface
12+ {
13+ public function getDriver (string $ role = self ::ROLE_WRITE ): object
14+ {
15+ return new stdClass ();
16+ }
17+
18+ public function setCacher (CacheInterface $ cacher )
19+ {
20+ return $ this ;
21+ }
22+
23+ public function getCacher (): CacheInterface
24+ {
25+ return Cache::pool ('_simple_connection_stub_ ' );
26+ }
27+
28+ public function configName (): string
29+ {
30+ return 'simple_connection_stub ' ;
31+ }
32+
33+ public function config (): array
34+ {
35+ return [];
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments