Skip to content

Commit 4dcf1bb

Browse files
committed
convert to PHPUnit 10
1 parent 63162be commit 4dcf1bb

9 files changed

Lines changed: 25 additions & 17 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ nbproject/*
1212
.vscode
1313
.DS_Store
1414
.cache
15+
.phpunit.cache
1516
.project
1617
.settings
1718
.svn

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"require-dev": {
3131
"cakephp/authorization": "3.x-dev",
3232
"cakephp/cakephp-codesniffer": "5.x-dev",
33-
"phpunit/phpunit": "^9.5.19"
33+
"phpunit/phpunit": "^10.1.0"
3434
},
3535
"autoload": {
3636
"psr-4": {

phpunit.xml.dist

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
colors="true"
4+
processIsolation="false"
5+
stopOnFailure="false"
6+
cacheDirectory=".phpunit.cache"
7+
bootstrap="./tests/bootstrap.php"
8+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
9+
>
310
<testsuites>
411
<testsuite name="debug-kit">
512
<directory>tests/TestCase</directory>
613
</testsuite>
714
</testsuites>
815

916
<extensions>
10-
<extension class="Cake\TestSuite\Fixture\PHPUnitExtension"/>
17+
<bootstrap class="Cake\TestSuite\Fixture\Extension\PHPUnitExtension"/>
1118
</extensions>
1219

13-
<coverage>
20+
<source>
1421
<include>
1522
<directory suffix=".php">src/</directory>
1623
</include>
17-
</coverage>
24+
</source>
1825

1926
<php>
2027
<ini name="memory_limit" value="-1"/>

src/ToolbarService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function registry(): PanelRegistry
102102
*/
103103
public function isEnabled(): bool
104104
{
105-
if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
105+
if (defined('PHPUNIT_COMPOSER_INSTALL') && !$GLOBALS['FORCE_DEBUGKIT_TOOLBAR']) {
106106
return false;
107107
}
108108
$enabled = (bool)Configure::read('debug')

tests/TestCase/Database/Log/DebugLogTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function testLogIgnoreReflectionDisabled($sql)
109109
$this->assertCount(1, $logger->queries());
110110
}
111111

112-
public function schemaQueryProvider()
112+
public static function schemaQueryProvider()
113113
{
114114
return [
115115
// MySQL

tests/TestCase/Middleware/DebugKitMiddlewareTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function setUp(): void
5555
$connection = ConnectionManager::get('test');
5656
$this->skipIf($connection->getDriver() instanceof Sqlite, 'Schema insertion/removal breaks SQLite');
5757
$this->oldConfig = Configure::read('DebugKit');
58-
$this->restore = $GLOBALS['__PHPUNIT_BOOTSTRAP'];
59-
unset($GLOBALS['__PHPUNIT_BOOTSTRAP']);
58+
$this->restore = $GLOBALS['FORCE_DEBUGKIT_TOOLBAR'];
59+
$GLOBALS['FORCE_DEBUGKIT_TOOLBAR'] = true;
6060
}
6161

6262
/**
@@ -69,7 +69,7 @@ public function tearDown(): void
6969
parent::tearDown();
7070

7171
Configure::write('DebugKit', $this->oldConfig);
72-
$GLOBALS['__PHPUNIT_BOOTSTRAP'] = $this->restore;
72+
$GLOBALS['FORCE_DEBUGKIT_TOOLBAR'] = $this->restore;
7373
}
7474

7575
protected function handler()
@@ -125,7 +125,7 @@ public function testInvokeSaveData()
125125
$this->assertNotNull($result->panels[11]->summary);
126126
$this->assertSame('Sql Log', $result->panels[11]->title);
127127

128-
$timeStamp = filemtime(Plugin::path('DebugKit') . 'webroot' . DS . 'js' . DS . 'main.js');
128+
$timeStamp = filectime(Plugin::path('DebugKit') . 'webroot' . DS . 'js' . DS . 'main.js');
129129

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

tests/TestCase/Panel/PackagesPanelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function setUp(): void
4444
*
4545
* @return array
4646
*/
47-
public function packagesProvider()
47+
public static function packagesProvider()
4848
{
4949
return [
5050
'requirements' => ['packages'],

tests/TestCase/ToolbarServiceTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public function setUp(): void
5858

5959
$connection = ConnectionManager::get('test');
6060
$this->skipIf($connection->getDriver() instanceof Sqlite, 'Schema insertion/removal breaks SQLite');
61-
$this->restore = $GLOBALS['__PHPUNIT_BOOTSTRAP'];
62-
unset($GLOBALS['__PHPUNIT_BOOTSTRAP']);
61+
$this->restore = $GLOBALS['FORCE_DEBUGKIT_TOOLBAR'];
62+
$GLOBALS['FORCE_DEBUGKIT_TOOLBAR'] = true;
6363
}
6464

6565
/**
@@ -71,7 +71,7 @@ public function tearDown(): void
7171
{
7272
parent::tearDown();
7373
putenv('HTTP_HOST=');
74-
$GLOBALS['__PHPUNIT_BOOTSTRAP'] = $this->restore;
74+
$GLOBALS['FORCE_DEBUGKIT_TOOLBAR'] = $this->restore;
7575
}
7676

7777
/**
@@ -417,7 +417,7 @@ public function testIsEnabledProductionEnv($domain, $isEnabled)
417417
$this->assertTrue($bar->isEnabled(), 'When forced should always be on.');
418418
}
419419

420-
public function domainsProvider()
420+
public static function domainsProvider()
421421
{
422422
return [
423423
['localhost', true],

tests/TestCase/View/Helper/CredentialsHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testFilter($in, $out)
7575
*
7676
* @return array input, expected output
7777
*/
78-
public function credentialsProvider()
78+
public static function credentialsProvider()
7979
{
8080
return [
8181
[null, null],

0 commit comments

Comments
 (0)