Skip to content

Commit 0a6f974

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
2 parents 7a34315 + 9dd92e0 commit 0a6f974

File tree

4 files changed

+25
-54
lines changed

4 files changed

+25
-54
lines changed

admin/framework/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"kint-php/kint": "^4.2",
1818
"codeigniter/coding-standard": "^1.5",
1919
"fakerphp/faker": "^1.9",
20-
"friendsofphp/php-cs-fixer": "~3.12.0",
20+
"friendsofphp/php-cs-fixer": "~3.13.0",
2121
"mikey179/vfsstream": "^1.6",
2222
"nexusphp/cs-config": "^3.6",
2323
"phpunit/phpunit": "^9.1",
@@ -38,6 +38,7 @@
3838
"ext-redis": "If you use Cache class RedisHandler",
3939
"ext-dom": "If you use TestResponse",
4040
"ext-libxml": "If you use TestResponse",
41+
"ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()",
4142
"ext-fileinfo": "Improves mime type detection for files",
4243
"ext-readline": "Improves CLI::input() usability"
4344
},

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"kint-php/kint": "^4.2",
1818
"codeigniter/coding-standard": "^1.5",
1919
"fakerphp/faker": "^1.9",
20-
"friendsofphp/php-cs-fixer": "~3.12.0",
20+
"friendsofphp/php-cs-fixer": "~3.13.0",
2121
"mikey179/vfsstream": "^1.6",
2222
"nexusphp/cs-config": "^3.6",
2323
"nexusphp/tachycardia": "^1.0",
@@ -44,6 +44,7 @@
4444
"ext-redis": "If you use Cache class RedisHandler",
4545
"ext-dom": "If you use TestResponse",
4646
"ext-libxml": "If you use TestResponse",
47+
"ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()",
4748
"ext-fileinfo": "Improves mime type detection for files",
4849
"ext-readline": "Improves CLI::input() usability"
4950
},

system/Debug/Toolbar.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ public function prepare(?RequestInterface $request = null, ?ResponseInterface $r
400400
$kintScript = @Kint::dump('');
401401
Kint::$mode_default = $oldKintMode;
402402
$kintScript = substr($kintScript, 0, strpos($kintScript, '</style>') + 8);
403+
$kintScript = ($kintScript === '0') ? '' : $kintScript;
403404

404405
$script = PHP_EOL
405406
. '<script ' . csp_script_nonce() . ' id="debugbar_loader" '

system/Test/CIUnitTestCase.php

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -405,60 +405,31 @@ public function assertEventTriggered(string $eventName): bool
405405
}
406406

407407
/**
408-
* Hooks into xdebug's headers capture, looking for a specific header
409-
* emitted
408+
* Hooks into xdebug's headers capture, looking for presence of
409+
* a specific header emitted.
410410
*
411411
* @param string $header The leading portion of the header we are looking for
412-
*
413-
* @throws Exception
414412
*/
415413
public function assertHeaderEmitted(string $header, bool $ignoreCase = false): void
416414
{
417-
$found = false;
418-
419-
if (! function_exists('xdebug_get_headers')) {
420-
$this->markTestSkipped('XDebug not found.');
421-
}
422-
423-
foreach (xdebug_get_headers() as $emitted) {
424-
$found = $ignoreCase ?
425-
(stripos($emitted, $header) === 0) :
426-
(strpos($emitted, $header) === 0);
427-
if ($found) {
428-
break;
429-
}
430-
}
431-
432-
$this->assertTrue($found, "Didn't find header for {$header}");
415+
$this->assertNotNull(
416+
$this->getHeaderEmitted($header, $ignoreCase, __METHOD__),
417+
"Didn't find header for {$header}"
418+
);
433419
}
434420

435421
/**
436-
* Hooks into xdebug's headers capture, looking for a specific header
437-
* emitted
422+
* Hooks into xdebug's headers capture, looking for absence of
423+
* a specific header emitted.
438424
*
439425
* @param string $header The leading portion of the header we don't want to find
440-
*
441-
* @throws Exception
442426
*/
443427
public function assertHeaderNotEmitted(string $header, bool $ignoreCase = false): void
444428
{
445-
$found = false;
446-
447-
if (! function_exists('xdebug_get_headers')) {
448-
$this->markTestSkipped('XDebug not found.');
449-
}
450-
451-
foreach (xdebug_get_headers() as $emitted) {
452-
$found = $ignoreCase ?
453-
(stripos($emitted, $header) === 0) :
454-
(strpos($emitted, $header) === 0);
455-
if ($found) {
456-
break;
457-
}
458-
}
459-
460-
$success = ! $found;
461-
$this->assertTrue($success, "Found header for {$header}");
429+
$this->assertNull(
430+
$this->getHeaderEmitted($header, $ignoreCase, __METHOD__),
431+
"Found header for {$header}"
432+
);
462433
}
463434

464435
/**
@@ -533,23 +504,20 @@ protected function createApplication()
533504

534505
/**
535506
* Return first matching emitted header.
536-
*
537-
* @param string $header Identifier of the header of interest
538-
*
539-
* @return string|null The value of the header found, null if not found
540507
*/
541-
protected function getHeaderEmitted(string $header, bool $ignoreCase = false): ?string
508+
protected function getHeaderEmitted(string $header, bool $ignoreCase = false, string $method = __METHOD__): ?string
542509
{
543510
if (! function_exists('xdebug_get_headers')) {
544-
$this->markTestSkipped('XDebug not found.');
511+
$this->markTestSkipped($method . '() requires xdebug.');
545512
}
546513

547-
foreach (xdebug_get_headers() as $emitted) {
548-
$found = $ignoreCase ?
549-
(stripos($emitted, $header) === 0) :
550-
(strpos($emitted, $header) === 0);
514+
foreach (xdebug_get_headers() as $emittedHeader) {
515+
$found = $ignoreCase
516+
? (stripos($emittedHeader, $header) === 0)
517+
: (strpos($emittedHeader, $header) === 0);
518+
551519
if ($found) {
552-
return $emitted;
520+
return $emittedHeader;
553521
}
554522
}
555523

0 commit comments

Comments
 (0)