Skip to content

Commit 5c4f60a

Browse files
authored
Merge pull request #996 from cakephp/fix-build
Fix build
2 parents 253ae96 + cedbd66 commit 5c4f60a

3 files changed

Lines changed: 33 additions & 11 deletions

File tree

tests/TestCase/FixtureFactoryTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ protected function makePanel($request, $name = 'DebugKit.Request', $title = 'Req
5151
'cookie' => Debugger::exportVarAsNodes([
5252
'toolbarDisplay' => 'show',
5353
]),
54+
'params' => [
55+
'plugin' => null,
56+
'controller' => 'Tasks',
57+
'action' => 'add',
58+
'_ext' => null,
59+
'pass' => [],
60+
],
5461
];
5562
}
5663
$panels = $this->getTableLocator()->get('DebugKit.Panels');

tests/TestCase/Middleware/DebugKitMiddlewareTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ class DebugKitMiddlewareTest extends TestCase
4242
'plugin.DebugKit.Panels',
4343
];
4444

45-
protected $oldConfig;
45+
protected ?array $oldConfig;
46+
47+
/**
48+
* @var bool
49+
*/
50+
protected bool $restore = false;
4651

4752
/**
4853
* setup
@@ -56,7 +61,7 @@ public function setUp(): void
5661
$connection = ConnectionManager::get('test');
5762
$this->skipIf($connection->getDriver() instanceof Sqlite, 'This test fails in CI with sqlite');
5863
$this->oldConfig = Configure::read('DebugKit');
59-
$this->restore = $GLOBALS['FORCE_DEBUGKIT_TOOLBAR'];
64+
$this->restore = $GLOBALS['FORCE_DEBUGKIT_TOOLBAR'] ?? false;
6065
$GLOBALS['FORCE_DEBUGKIT_TOOLBAR'] = true;
6166
}
6267

@@ -126,7 +131,7 @@ public function testInvokeSaveData()
126131
$this->assertNotNull($result->panels[11]->summary);
127132
$this->assertSame('Sql Log', $result->panels[11]->title);
128133

129-
$timeStamp = filectime(Plugin::path('DebugKit') . 'webroot' . DS . 'js' . DS . 'main.js');
134+
$timeStamp = filectime(Plugin::path('DebugKit') . 'webroot' . DS . 'js' . DS . 'inject-iframe.js');
130135

131136
$expected = '<html><title>test</title><body><p>some text</p>' .
132137
'<script id="__debug_kit_script" data-id="' . $result->id . '" ' .

tests/TestCase/ToolbarServiceTest.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Cake\Routing\Router;
2626
use Cake\TestSuite\TestCase;
2727
use DebugKit\Model\Entity\Request as RequestEntity;
28+
use DebugKit\Panel\SqlLogPanel;
2829
use 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

Comments
 (0)