2525use Cake \Routing \Router ;
2626use Cake \TestSuite \TestCase ;
2727use DebugKit \Model \Entity \Request as RequestEntity ;
28+ use DebugKit \Panel \SqlLogPanel ;
2829use DebugKit \ToolbarService ;
2930
3031/**
@@ -42,6 +43,11 @@ class ToolbarServiceTest extends TestCase
4243 'plugin.DebugKit.Panels ' ,
4344 ];
4445
46+ /**
47+ * @var bool
48+ */
49+ protected bool $ restore = false ;
50+
4551 /**
4652 * @var EventManager
4753 */
@@ -59,7 +65,7 @@ public function setUp(): void
5965
6066 $ connection = ConnectionManager::get ('test ' );
6167 $ this ->skipIf ($ connection ->getDriver () instanceof Sqlite, 'Schema insertion/removal breaks SQLite ' );
62- $ this ->restore = $ GLOBALS ['FORCE_DEBUGKIT_TOOLBAR ' ];
68+ $ this ->restore = $ GLOBALS ['FORCE_DEBUGKIT_TOOLBAR ' ] ?? false ;
6369 $ GLOBALS ['FORCE_DEBUGKIT_TOOLBAR ' ] = true ;
6470 }
6571
@@ -87,7 +93,7 @@ public function testLoadPanels()
8793
8894 $ this ->assertContains ('SqlLog ' , $ bar ->loadedPanels ());
8995 $ this ->assertGreaterThan (1 , $ this ->events ->listeners ('Controller.shutdown ' ));
90- $ this ->assertInstanceOf (' DebugKit\Panel\ SqlLogPanel' , $ bar ->panel ('SqlLog ' ));
96+ $ this ->assertInstanceOf (SqlLogPanel::class , $ bar ->panel ('SqlLog ' ));
9197 }
9298
9399 /**
@@ -100,7 +106,7 @@ public function testDisablePanels()
100106 $ bar = new ToolbarService ($ this ->events , ['panels ' => [
101107 'DebugKit.SqlLog ' => false ,
102108 'DebugKit.Cache ' => true ,
103- 'DebugKit.Session ' ,
109+ 'DebugKit.Session ' => true ,
104110 ]]);
105111 $ bar ->loadPanels ();
106112
@@ -239,7 +245,7 @@ public function testSaveData()
239245
240246 $ requests = $ this ->getTableLocator ()->get ('DebugKit.Requests ' );
241247 $ result = $ requests ->find ()
242- ->order (['Requests.requested_at ' => 'DESC ' ])
248+ ->orderBy (['Requests.requested_at ' => 'DESC ' ])
243249 ->contain ('Panels ' )
244250 ->first ();
245251
@@ -305,6 +311,8 @@ public function testInjectScriptsLastBodyTag()
305311 $ bar = new ToolbarService ($ this ->events , []);
306312 $ bar ->loadPanels ();
307313 $ row = $ bar ->saveData ($ request , $ response );
314+ $ this ->assertNotEmpty ($ row );
315+ /** @var \DebugKit\Model\Entity\Request $row */
308316 $ response = $ bar ->injectScripts ($ row , $ response );
309317
310318 $ timeStamp = filemtime (Plugin::path ('DebugKit ' ) . 'webroot ' . DS . 'js ' . DS . 'inject-iframe.js ' );
@@ -334,7 +342,7 @@ public function testInjectScriptsFileBodies()
334342 $ row = new RequestEntity (['id ' => 'abc123 ' ]);
335343
336344 $ result = $ bar ->injectScripts ($ row , $ response );
337- $ this ->assertInstanceOf (' Cake\Http\ Response' , $ result );
345+ $ this ->assertInstanceOf (Response::class , $ result );
338346 $ this ->assertSame (file_get_contents (__FILE__ ), '' . $ result ->getBody ());
339347 $ this ->assertTrue ($ result ->hasHeader ('X-DEBUGKIT-ID ' ), 'Should have a tracking id ' );
340348 }
@@ -356,7 +364,7 @@ public function testInjectScriptsStreamBodies()
356364 $ row = new RequestEntity (['id ' => 'abc123 ' ]);
357365
358366 $ result = $ bar ->injectScripts ($ row , $ response );
359- $ this ->assertInstanceOf (' Cake\Http\ Response' , $ result );
367+ $ this ->assertInstanceOf (Response::class , $ result );
360368 $ this ->assertSame ('I am a teapot! ' , (string )$ response ->getBody ());
361369 }
362370
@@ -381,6 +389,8 @@ public function testInjectScriptsNoModifyResponse()
381389 $ bar ->loadPanels ();
382390
383391 $ row = $ bar ->saveData ($ request , $ response );
392+ $ this ->assertNotEmpty ($ row );
393+ /** @var \DebugKit\Model\Entity\Request $row */
384394 $ response = $ bar ->injectScripts ($ row , $ response );
385395 $ this ->assertTextEquals ('{"some":"json"} ' , (string )$ response ->getBody ());
386396 $ this ->assertTrue ($ response ->hasHeader ('X-DEBUGKIT-ID ' ), 'Should have a tracking id ' );
@@ -410,7 +420,7 @@ public function testIsEnabled()
410420 * @dataProvider domainsProvider
411421 * @return void
412422 */
413- public function testIsEnabledProductionEnv ($ domain , $ isEnabled )
423+ public function testIsEnabledProductionEnv (string $ domain , bool $ isEnabled )
414424 {
415425 Configure::write ('debug ' , true );
416426 putenv ("HTTP_HOST= $ domain " );
@@ -421,7 +431,7 @@ public function testIsEnabledProductionEnv($domain, $isEnabled)
421431 $ this ->assertTrue ($ bar ->isEnabled (), 'When forced should always be on. ' );
422432 }
423433
424- public static function domainsProvider ()
434+ public static function domainsProvider (): array
425435 {
426436 return [
427437 ['localhost ' , true ],
0 commit comments