From 4dcf1bbbb4563fe13f17611d37586f000dfbc390 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 30 May 2023 20:51:11 +0200 Subject: [PATCH] convert to PHPUnit 10 --- .gitignore | 1 + composer.json | 2 +- phpunit.xml.dist | 15 +++++++++++---- src/ToolbarService.php | 2 +- tests/TestCase/Database/Log/DebugLogTest.php | 2 +- .../Middleware/DebugKitMiddlewareTest.php | 8 ++++---- tests/TestCase/Panel/PackagesPanelTest.php | 2 +- tests/TestCase/ToolbarServiceTest.php | 8 ++++---- .../View/Helper/CredentialsHelperTest.php | 2 +- 9 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 1b4b968a..601dfedd 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ nbproject/* .vscode .DS_Store .cache +.phpunit.cache .project .settings .svn diff --git a/composer.json b/composer.json index 07faa1af..97e2ddbb 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "require-dev": { "cakephp/authorization": "3.x-dev", "cakephp/cakephp-codesniffer": "5.x-dev", - "phpunit/phpunit": "^9.5.19" + "phpunit/phpunit": "^10.1.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0a92627f..2c9f81ea 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,12 @@ - + tests/TestCase @@ -7,14 +14,14 @@ - + - + src/ - + diff --git a/src/ToolbarService.php b/src/ToolbarService.php index b00ca65b..fc548291 100644 --- a/src/ToolbarService.php +++ b/src/ToolbarService.php @@ -102,7 +102,7 @@ public function registry(): PanelRegistry */ public function isEnabled(): bool { - if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) { + if (defined('PHPUNIT_COMPOSER_INSTALL') && !$GLOBALS['FORCE_DEBUGKIT_TOOLBAR']) { return false; } $enabled = (bool)Configure::read('debug') diff --git a/tests/TestCase/Database/Log/DebugLogTest.php b/tests/TestCase/Database/Log/DebugLogTest.php index 704a8a46..170ba2cf 100644 --- a/tests/TestCase/Database/Log/DebugLogTest.php +++ b/tests/TestCase/Database/Log/DebugLogTest.php @@ -109,7 +109,7 @@ public function testLogIgnoreReflectionDisabled($sql) $this->assertCount(1, $logger->queries()); } - public function schemaQueryProvider() + public static function schemaQueryProvider() { return [ // MySQL diff --git a/tests/TestCase/Middleware/DebugKitMiddlewareTest.php b/tests/TestCase/Middleware/DebugKitMiddlewareTest.php index 163b696f..b1c97aed 100644 --- a/tests/TestCase/Middleware/DebugKitMiddlewareTest.php +++ b/tests/TestCase/Middleware/DebugKitMiddlewareTest.php @@ -55,8 +55,8 @@ public function setUp(): void $connection = ConnectionManager::get('test'); $this->skipIf($connection->getDriver() instanceof Sqlite, 'Schema insertion/removal breaks SQLite'); $this->oldConfig = Configure::read('DebugKit'); - $this->restore = $GLOBALS['__PHPUNIT_BOOTSTRAP']; - unset($GLOBALS['__PHPUNIT_BOOTSTRAP']); + $this->restore = $GLOBALS['FORCE_DEBUGKIT_TOOLBAR']; + $GLOBALS['FORCE_DEBUGKIT_TOOLBAR'] = true; } /** @@ -69,7 +69,7 @@ public function tearDown(): void parent::tearDown(); Configure::write('DebugKit', $this->oldConfig); - $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $this->restore; + $GLOBALS['FORCE_DEBUGKIT_TOOLBAR'] = $this->restore; } protected function handler() @@ -125,7 +125,7 @@ public function testInvokeSaveData() $this->assertNotNull($result->panels[11]->summary); $this->assertSame('Sql Log', $result->panels[11]->title); - $timeStamp = filemtime(Plugin::path('DebugKit') . 'webroot' . DS . 'js' . DS . 'main.js'); + $timeStamp = filectime(Plugin::path('DebugKit') . 'webroot' . DS . 'js' . DS . 'main.js'); $expected = 'test

some text

' . '