diff --git a/.gitignore b/.gitignore index 81be26977..1e99c41a5 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ nbproject/* .svn errors.err tags +/.phpunit.result.cache /nbproject/ /composer.lock /vendor diff --git a/.travis.yml b/.travis.yml index 075881bbf..60e129fbd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: php php: - - 7.1 - 7.2 + - 7.3 dist: trusty diff --git a/composer.json b/composer.json index af053ad9d..3fe83ac5c 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ }, "require-dev": { "cakephp/cakephp-codesniffer": "dev-next", - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^8.0" }, "autoload": { "psr-4": { diff --git a/src/Controller/MailPreviewController.php b/src/Controller/MailPreviewController.php index c790bb0e8..f4619d554 100644 --- a/src/Controller/MailPreviewController.php +++ b/src/Controller/MailPreviewController.php @@ -122,7 +122,7 @@ public function email($name, $method) $email = $this->findPreview($name, $method, $plugin); $partType = $this->request->getQuery('part'); - $this->viewBuilder()->setLayout(false); + $this->viewBuilder()->disableAutoLayout(); if ($partType) { return $this->respondWithPart($email, $partType); diff --git a/tests/TestCase/Cache/Engine/DebugEngineTest.php b/tests/TestCase/Cache/Engine/DebugEngineTest.php index 9b57ae5b1..8cd8f67b8 100644 --- a/tests/TestCase/Cache/Engine/DebugEngineTest.php +++ b/tests/TestCase/Cache/Engine/DebugEngineTest.php @@ -14,6 +14,7 @@ */ namespace DebugKit\Test\TestCase\Cache\Engine; +use BadMethodCallException; use Cake\TestSuite\TestCase; use DebugKit\Cache\Engine\DebugEngine; use DebugKit\DebugTimer; @@ -38,7 +39,7 @@ class DebugEngineTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $mock = $this->getMockBuilder('Cake\Cache\CacheEngine')->getMock(); @@ -66,11 +67,11 @@ public function testInitEngineBasedOnConfig() /** * Test that the normal errors bubble up still. * - * @expectedException BadMethodCallException * @return void */ public function testInitErrorOnInvalidConfig() { + $this->expectException(BadMethodCallException::class); $engine = new DebugEngine([ 'className' => 'Derpy', 'path' => TMP, diff --git a/tests/TestCase/Controller/MailPreviewControllerTest.php b/tests/TestCase/Controller/MailPreviewControllerTest.php index 8b0cd81b7..5feaa240c 100644 --- a/tests/TestCase/Controller/MailPreviewControllerTest.php +++ b/tests/TestCase/Controller/MailPreviewControllerTest.php @@ -40,7 +40,7 @@ class MailPreviewControllerTest extends IntegrationTestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/TestCase/Controller/PanelsControllerTest.php b/tests/TestCase/Controller/PanelsControllerTest.php index c2c233767..bdb93abb0 100644 --- a/tests/TestCase/Controller/PanelsControllerTest.php +++ b/tests/TestCase/Controller/PanelsControllerTest.php @@ -38,7 +38,7 @@ class PanelsControllerTest extends IntegrationTestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); Router::plugin('DebugKit', function (RouteBuilder $routes) { diff --git a/tests/TestCase/Controller/RequestsControllerTest.php b/tests/TestCase/Controller/RequestsControllerTest.php index 2d9eef978..f1484dfd1 100644 --- a/tests/TestCase/Controller/RequestsControllerTest.php +++ b/tests/TestCase/Controller/RequestsControllerTest.php @@ -38,7 +38,7 @@ class RequestsControllerTest extends IntegrationTestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); Router::plugin('DebugKit', function (RouteBuilder $routes) { diff --git a/tests/TestCase/Controller/ToolbarControllerTest.php b/tests/TestCase/Controller/ToolbarControllerTest.php index f4dad2d0f..0407d93da 100644 --- a/tests/TestCase/Controller/ToolbarControllerTest.php +++ b/tests/TestCase/Controller/ToolbarControllerTest.php @@ -39,7 +39,7 @@ class ToolbarControllerTest extends IntegrationTestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); Router::plugin('DebugKit', function (RouteBuilder $routes) { diff --git a/tests/TestCase/Database/Log/DebugLogTest.php b/tests/TestCase/Database/Log/DebugLogTest.php index 09daa8a49..1230f3a84 100644 --- a/tests/TestCase/Database/Log/DebugLogTest.php +++ b/tests/TestCase/Database/Log/DebugLogTest.php @@ -32,7 +32,7 @@ class DebugLogTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->logger = new DebugLog(null, 'test'); diff --git a/tests/TestCase/DebugIncludeTest.php b/tests/TestCase/DebugIncludeTest.php index e7754a6e2..6d1a76cb6 100644 --- a/tests/TestCase/DebugIncludeTest.php +++ b/tests/TestCase/DebugIncludeTest.php @@ -26,7 +26,7 @@ public function testIncludePaths() { $include = new DebugInclude(); $result = $include->includePaths(); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertFileExists($result[0]); } diff --git a/tests/TestCase/DebugMemoryTest.php b/tests/TestCase/DebugMemoryTest.php index dd7601748..ca11f3085 100644 --- a/tests/TestCase/DebugMemoryTest.php +++ b/tests/TestCase/DebugMemoryTest.php @@ -47,7 +47,7 @@ public function testRecordNoKey() DebugMemory::record(); $result = DebugMemory::getAll(true); $this->assertCount(1, $result); - $this->assertContains('DebugMemoryTest.php line ' . (__LINE__ - 3), array_keys($result)[0]); + $this->assertStringContainsString('DebugMemoryTest.php line ' . (__LINE__ - 3), array_keys($result)[0]); } /** diff --git a/tests/TestCase/DebugPanelTest.php b/tests/TestCase/DebugPanelTest.php index 341477b51..ea7f18187 100644 --- a/tests/TestCase/DebugPanelTest.php +++ b/tests/TestCase/DebugPanelTest.php @@ -27,7 +27,7 @@ class DebugPanelTest extends TestCase */ protected $panel; - public function setUp() + public function setUp(): void { parent::setUp(); $this->panel = new SimplePanel(); diff --git a/tests/TestCase/DebugSqlTest.php b/tests/TestCase/DebugSqlTest.php index 48008db99..0aac66e7d 100644 --- a/tests/TestCase/DebugSqlTest.php +++ b/tests/TestCase/DebugSqlTest.php @@ -34,7 +34,7 @@ class DebugSqlTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->connection = ConnectionManager::get('test'); diff --git a/tests/TestCase/DebugTimerTest.php b/tests/TestCase/DebugTimerTest.php index 71a229e18..275338e88 100644 --- a/tests/TestCase/DebugTimerTest.php +++ b/tests/TestCase/DebugTimerTest.php @@ -28,7 +28,7 @@ class DebugTimerTest extends TestCase * * @return void */ - public function tearDown() + public function tearDown(): void { DebugTimer::clear(); } diff --git a/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php b/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php index 2bb44d8ea..4132acaa8 100644 --- a/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php +++ b/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php @@ -20,7 +20,7 @@ class DebugKitTransportTest extends TestCase { - public function setUp() + public function setUp(): void { $this->log = new \ArrayObject(); $this->wrapped = $this->getMockBuilder(AbstractTransport::class) diff --git a/tests/TestCase/Middleware/DebugKitMiddlewareTest.php b/tests/TestCase/Middleware/DebugKitMiddlewareTest.php index c22757910..1ffb5c51d 100644 --- a/tests/TestCase/Middleware/DebugKitMiddlewareTest.php +++ b/tests/TestCase/Middleware/DebugKitMiddlewareTest.php @@ -44,7 +44,7 @@ class DebugKitMiddlewareTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); @@ -58,7 +58,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); @@ -150,8 +150,8 @@ public function testInvokeNoModifyBinaryResponse() $this->assertEquals(1, $total, 'Should track response'); $body = $result->getBody(); - $this->assertNotContains('__debug_kit', '' . $body); - $this->assertNotContains('assertStringNotContainsString('__debug_kit', '' . $body); + $this->assertStringNotContainsString('assertEquals(0, $total, 'Should not track sub-requests'); $body = $result->getBody(); - $this->assertNotContains('assertStringNotContainsString('Article = TableRegistry::get('Articles'); @@ -52,7 +52,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); unset($this->Article); diff --git a/tests/TestCase/Model/Table/RequestTableTest.php b/tests/TestCase/Model/Table/RequestTableTest.php index e479afc7d..8759faf1f 100644 --- a/tests/TestCase/Model/Table/RequestTableTest.php +++ b/tests/TestCase/Model/Table/RequestTableTest.php @@ -31,7 +31,7 @@ class RequestTableTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $connection = ConnectionManager::get('test'); diff --git a/tests/TestCase/Panel/CachePanelTest.php b/tests/TestCase/Panel/CachePanelTest.php index 06eb47b38..9d72cbd3d 100644 --- a/tests/TestCase/Panel/CachePanelTest.php +++ b/tests/TestCase/Panel/CachePanelTest.php @@ -32,7 +32,7 @@ class CachePanelTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->panel = new CachePanel(); @@ -44,7 +44,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); Cache::drop('debug_kit_test'); diff --git a/tests/TestCase/Panel/DeprecationsPanelTest.php b/tests/TestCase/Panel/DeprecationsPanelTest.php index 9c2abcdca..f0a2e9730 100644 --- a/tests/TestCase/Panel/DeprecationsPanelTest.php +++ b/tests/TestCase/Panel/DeprecationsPanelTest.php @@ -33,7 +33,7 @@ class DeprecationsPanelTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); DeprecationsPanel::clearDeprecatedErrors(); @@ -64,12 +64,12 @@ public function testShutdown() $this->assertCount(3, $data['plugins']['DebugKit']); $error = $data['plugins']['DebugKit'][0]; - $this->assertContains('Something going away', $error['message']); + $this->assertStringContainsString('Something going away', $error['message']); $this->assertEquals('DebugKit/tests/TestCase/Panel/DeprecationsPanelTest.php', $error['niceFile']); $this->assertEquals(46, $error['line']); $error = $data['plugins']['DebugKit'][2]; - $this->assertContains('Raw error', $error['message']); + $this->assertStringContainsString('Raw error', $error['message']); $this->assertEquals('DebugKit/tests/TestCase/Panel/DeprecationsPanelTest.php', $error['niceFile']); $this->assertEquals(48, $error['line']); } diff --git a/tests/TestCase/Panel/EnvironmentPanelTest.php b/tests/TestCase/Panel/EnvironmentPanelTest.php index 63aca7539..41342bb90 100644 --- a/tests/TestCase/Panel/EnvironmentPanelTest.php +++ b/tests/TestCase/Panel/EnvironmentPanelTest.php @@ -33,7 +33,7 @@ class EnvironmentPanelTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->panel = new EnvironmentPanel(); @@ -44,7 +44,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); unset($this->panel); @@ -63,7 +63,7 @@ public function testShutdown() $this->panel->shutdown($event); $output = $this->panel->data(); - $this->assertInternalType('array', $output); + $this->assertIsArray($output); $this->assertSame(['php', 'ini', 'cake', 'app'], array_keys($output)); $this->assertEquals('mysql://user:password@localhost/my_db', $output['php']['TEST_URL_1']); } diff --git a/tests/TestCase/Panel/IncludePanelTest.php b/tests/TestCase/Panel/IncludePanelTest.php index 35eca4fc6..01ca389a8 100644 --- a/tests/TestCase/Panel/IncludePanelTest.php +++ b/tests/TestCase/Panel/IncludePanelTest.php @@ -33,7 +33,7 @@ class IncludePanelTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->panel = new IncludePanel(); diff --git a/tests/TestCase/Panel/LogPanelTest.php b/tests/TestCase/Panel/LogPanelTest.php index 47cf34881..de992370b 100644 --- a/tests/TestCase/Panel/LogPanelTest.php +++ b/tests/TestCase/Panel/LogPanelTest.php @@ -33,7 +33,7 @@ class LogPanelTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->panel = new LogPanel(); @@ -44,7 +44,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); Log::drop('debug_kit_log_panel'); @@ -77,7 +77,7 @@ public function testData() $result = $this->panel->data(); $this->assertArrayHasKey('logger', $result); - /* @var DebugKitLog $logger */ + /** @var DebugKitLog $logger */ $logger = $result['logger']; $this->assertInstanceOf('DebugKit\Log\Engine\DebugKitLog', $logger); diff --git a/tests/TestCase/Panel/PackagesPanelTest.php b/tests/TestCase/Panel/PackagesPanelTest.php index e88ae4e6e..9c7b00fce 100644 --- a/tests/TestCase/Panel/PackagesPanelTest.php +++ b/tests/TestCase/Panel/PackagesPanelTest.php @@ -33,7 +33,7 @@ class PackagesPanelTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->panel = new PackagesPanel(); diff --git a/tests/TestCase/Panel/RoutesPanelTest.php b/tests/TestCase/Panel/RoutesPanelTest.php index 225bff5b4..50889f335 100644 --- a/tests/TestCase/Panel/RoutesPanelTest.php +++ b/tests/TestCase/Panel/RoutesPanelTest.php @@ -34,7 +34,7 @@ class RoutesPanelTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/TestCase/Panel/SqlLogPanelTest.php b/tests/TestCase/Panel/SqlLogPanelTest.php index 24917b272..3710d105b 100644 --- a/tests/TestCase/Panel/SqlLogPanelTest.php +++ b/tests/TestCase/Panel/SqlLogPanelTest.php @@ -18,6 +18,7 @@ use Cake\ORM\TableRegistry; use Cake\TestSuite\TestCase; use DebugKit\Panel\SqlLogPanel; +use ReflectionProperty; /** * Class SqlLogPanelTest @@ -46,14 +47,14 @@ class SqlLogPanelTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->panel = new SqlLogPanel(); $this->logger = ConnectionManager::get('test')->getLogger(); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); ConnectionManager::get('test')->setLogger($this->logger); @@ -88,7 +89,10 @@ public function testInitializePassesIncludeSchema() $db = ConnectionManager::get('test'); $logger = $db->getLogger(); $this->assertInstanceOf('DebugKit\Database\Log\DebugLog', $logger); - $this->assertAttributeEquals(true, '_includeSchema', $logger); + + $property = new ReflectionProperty($logger, '_includeSchema'); + $property->setAccessible(true); + $this->assertTrue($property->getValue($logger)); } /** @@ -100,7 +104,7 @@ public function testData() { $this->panel->initialize(); - /* @var Table $articles */ + /** @var Table $articles */ $articles = TableRegistry::get('Articles'); $articles->findById(1)->first(); @@ -117,7 +121,7 @@ public function testSummary() { $this->panel->initialize(); - /* @var Table $articles */ + /** @var Table $articles */ $articles = TableRegistry::get('Articles'); $articles->findById(1)->first(); diff --git a/tests/TestCase/Panel/VariablesPanelTest.php b/tests/TestCase/Panel/VariablesPanelTest.php index bb3b6fc32..742b81419 100644 --- a/tests/TestCase/Panel/VariablesPanelTest.php +++ b/tests/TestCase/Panel/VariablesPanelTest.php @@ -38,7 +38,7 @@ class VariablesPanelTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->panel = new VariablesPanel(); @@ -49,7 +49,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); unset($this->panel); @@ -110,7 +110,7 @@ public function testShutdown() } }); $this->assertRegExp('/^\[stream\] Resource id #\d+$/', $output['content']['resource']); - $this->assertInternalType('array', $output['content']['unserializableDebugInfo']); + $this->assertIsArray($output['content']['unserializableDebugInfo']); $this->assertStringStartsWith( 'Unserializable object - stdClass. Error: You cannot serialize or unserialize PDO instances', $output['content']['unserializableDebugInfo']['unserializable'] @@ -124,10 +124,10 @@ public function testShutdown() $controller->viewBuilder()->getVar('query'), 'Original value should not be mutated' ); - $this->assertInternalType('array', $output['content']['updateQuery']); - $this->assertInternalType('array', $output['content']['query']); - $this->assertInternalType('array', $output['content']['unbufferedQuery']); - $this->assertInternalType('array', $output['content']['result set']); + $this->assertIsArray($output['content']['updateQuery']); + $this->assertIsArray($output['content']['query']); + $this->assertIsArray($output['content']['unbufferedQuery']); + $this->assertIsArray($output['content']['result set']); $this->assertEquals($controller->viewBuilder()->getVar('string'), $output['content']['string']); $this->assertEquals($controller->viewBuilder()->getVar('array'), $output['content']['array']); } diff --git a/tests/TestCase/ToolbarServiceTest.php b/tests/TestCase/ToolbarServiceTest.php index ca721014d..fc9a412da 100644 --- a/tests/TestCase/ToolbarServiceTest.php +++ b/tests/TestCase/ToolbarServiceTest.php @@ -51,7 +51,7 @@ class ToolbarServiceTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->events = new EventManager(); @@ -65,7 +65,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); putenv('HTTP_HOST='); diff --git a/tests/TestCase/View/Helper/CredentialsHelperTest.php b/tests/TestCase/View/Helper/CredentialsHelperTest.php index 072d53846..0075edf16 100644 --- a/tests/TestCase/View/Helper/CredentialsHelperTest.php +++ b/tests/TestCase/View/Helper/CredentialsHelperTest.php @@ -39,7 +39,7 @@ class CredentialsHelperTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); @@ -54,7 +54,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); unset($this->Helper); diff --git a/tests/TestCase/View/Helper/SimpleGraphHelperTest.php b/tests/TestCase/View/Helper/SimpleGraphHelperTest.php index 94f271feb..884007174 100644 --- a/tests/TestCase/View/Helper/SimpleGraphHelperTest.php +++ b/tests/TestCase/View/Helper/SimpleGraphHelperTest.php @@ -40,7 +40,7 @@ class SimpleGraphHelperTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); Router::connect('/:controller/:action'); @@ -57,7 +57,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); unset($this->Graph); diff --git a/tests/TestCase/View/Helper/ToolbarHelperTest.php b/tests/TestCase/View/Helper/ToolbarHelperTest.php index 1ff722230..fa77f7b8b 100644 --- a/tests/TestCase/View/Helper/ToolbarHelperTest.php +++ b/tests/TestCase/View/Helper/ToolbarHelperTest.php @@ -41,7 +41,7 @@ class ToolbarHelperTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); Router::connect('/:controller/:action'); @@ -58,7 +58,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); unset($this->Toolbar); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f8823989f..2207fab30 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,6 +11,7 @@ * @link http://cakephp.org CakePHP(tm) Project * @license http://www.opensource.org/licenses/mit-license.php MIT License */ + use Cake\Cache\Cache; use Cake\Core\Configure; use Cake\Core\Plugin; @@ -20,6 +21,7 @@ require_once 'vendor/autoload.php'; // Path constants to a few helpful things. +define('DS', DIRECTORY_SEPARATOR); define('ROOT', dirname(__DIR__)); define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp'); define('CORE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp' . DS);