From 137f0ae7dd265b4654baf3f277008af3e540b58c Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 28 Jan 2020 22:58:06 -0500 Subject: [PATCH 1/3] Port fixes from #716 to master --- src/Command/BenchmarkCommand.php | 3 --- tests/TestCase/Panel/VariablesPanelTest.php | 8 +++++++- tests/TestCase/ToolbarServiceTest.php | 6 +----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Command/BenchmarkCommand.php b/src/Command/BenchmarkCommand.php index 9915cf0fe..83fc688fe 100644 --- a/src/Command/BenchmarkCommand.php +++ b/src/Command/BenchmarkCommand.php @@ -28,9 +28,6 @@ * functionally similar to Apache AB * * @since DebugKit 1.0 - * @todo Print/export time detail information - * @todo Export/graphing of data to .dot format for graphviz visualization - * @todo Make calculated results round to leading significant digit position of std dev. */ class BenchmarkCommand extends Command { diff --git a/tests/TestCase/Panel/VariablesPanelTest.php b/tests/TestCase/Panel/VariablesPanelTest.php index dc58d0fcd..5601108a9 100644 --- a/tests/TestCase/Panel/VariablesPanelTest.php +++ b/tests/TestCase/Panel/VariablesPanelTest.php @@ -112,8 +112,14 @@ public function testShutdown() }); $this->assertRegExp('/^\[stream\] Resource id #\d+$/', $output['content']['resource']); $this->assertIsArray($output['content']['unserializableDebugInfo']); + + if (version_compare(PHP_VERSION, '7.4.0', '>=')) { + $expectedErrorMessage = "Unserializable object - stdClass. Error: Serialization of 'PDO' is not allowed"; + } else { + $expectedErrorMessage = 'Unserializable object - stdClass. Error: You cannot serialize or unserialize PDO instances'; + } $this->assertStringStartsWith( - 'Unserializable object - stdClass. Error: You cannot serialize or unserialize PDO instances', + $expectedErrorMessage, $output['content']['unserializableDebugInfo']['unserializable'] ); $this->assertStringStartsWith( diff --git a/tests/TestCase/ToolbarServiceTest.php b/tests/TestCase/ToolbarServiceTest.php index 662945ec3..e017ce2ce 100644 --- a/tests/TestCase/ToolbarServiceTest.php +++ b/tests/TestCase/ToolbarServiceTest.php @@ -286,11 +286,7 @@ public function testInjectScriptsStreamBodies() $result = $bar->injectScripts($row, $response); $this->assertInstanceOf('Cake\Http\Response', $result); - if (version_compare(PHP_VERSION, '5.6.0', '>=')) { - $this->assertEquals('I am a teapot!', $response->getBody()); - } else { - $this->assertInstanceOf('Closure', $response->getBody()); - } + $this->assertEquals('I am a teapot!', $response->getBody()); } /** From f55d474cd6b473107259fb12eab37d6ed3d83f56 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 29 Jan 2020 16:28:06 -0500 Subject: [PATCH 2/3] Fix test. --- tests/TestCase/DebugSqlTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/TestCase/DebugSqlTest.php b/tests/TestCase/DebugSqlTest.php index d9f033afa..f1efcde66 100644 --- a/tests/TestCase/DebugSqlTest.php +++ b/tests/TestCase/DebugSqlTest.php @@ -14,7 +14,7 @@ */ namespace DebugKit\Test\TestCase; -use Cake\Database\Driver\Mysql; +use Cake\Database\Driver\Postgres; use Cake\Datasource\ConnectionManager; use Cake\ORM\TableRegistry; use Cake\TestSuite\TestCase; @@ -59,7 +59,7 @@ public function testSqlText() ########################### EXPECTED; - $fieldName = $this->connection->getDriver() instanceof Mysql ? '`panels__id`' : '"panels__id"'; + $fieldName = $this->connection->getDriver() instanceof Postgres ? '"panels__id"' : 'panels__id'; $expected = sprintf($expectedText, str_replace(ROOT, '', __FILE__), __LINE__ - 11, $fieldName); $this->assertEquals($expected, $result); } @@ -86,7 +86,7 @@ public function testSqlHtml() EXPECTED; - $fieldName = $this->connection->getDriver() instanceof Mysql ? '`panels__id`' : '"panels__id"'; + $fieldName = $this->connection->getDriver() instanceof Postgres ? '"panels__id"' : 'panels__id'; $expected = sprintf($expectedHtml, str_replace(ROOT, '', __FILE__), __LINE__ - 15, $fieldName); $this->assertEquals(str_replace("\r", '', $expected), str_replace("\r", '', $result)); } From 56e594bdd4c041f26444960f7be760e6dff84991 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 30 Jan 2020 23:31:48 -0500 Subject: [PATCH 3/3] Stop using extract() --- src/View/Helper/SimpleGraphHelper.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/View/Helper/SimpleGraphHelper.php b/src/View/Helper/SimpleGraphHelper.php index 8f2592ce2..ab387b7d3 100644 --- a/src/View/Helper/SimpleGraphHelper.php +++ b/src/View/Helper/SimpleGraphHelper.php @@ -55,10 +55,9 @@ class SimpleGraphHelper extends Helper public function bar($value, $offset, $options = []) { $settings = array_merge($this->_defaultSettings, $options); - /** @var int $max */ - /** @var int $width */ - /** @var string $valueType */ - extract($settings); + $max = $settings['max']; + $width = $settings['width']; + $valueType = $settings['valueType']; $graphValue = $value / $max * $width; $graphValue = max(round($graphValue), 1);