Skip to content

Commit 9c37908

Browse files
committed
test: add tests for Kint with CSP
1 parent 7062536 commit 9c37908

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/system/CommonFunctionsTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Config\Logger;
3030
use Config\Modules;
3131
use InvalidArgumentException;
32+
use Kint;
3233
use stdClass;
3334
use Tests\Support\Models\JobModel;
3435

@@ -482,4 +483,37 @@ public function testIsCli()
482483
$this->assertIsBool(is_cli());
483484
$this->assertTrue(is_cli());
484485
}
486+
487+
public function testDWithCSP()
488+
{
489+
/** @var App $config */
490+
$config = config(App::class);
491+
$CSPEnabled = $config->CSPEnabled;
492+
$cliDetection = Kint::$cli_detection;
493+
494+
$config->CSPEnabled = true;
495+
Kint::$cli_detection = false;
496+
497+
$this->expectOutputRegex('/<script {csp-script-nonce} class="kint-rich-script">/u');
498+
d('string');
499+
500+
// Restore settings
501+
$config->CSPEnabled = $CSPEnabled;
502+
Kint::$cli_detection = $cliDetection;
503+
}
504+
505+
/**
506+
* @runInSeparateProcess
507+
* @preserveGlobalState disabled
508+
*/
509+
public function testTraceWithCSP()
510+
{
511+
/** @var App $config */
512+
$config = config(App::class);
513+
$config->CSPEnabled = true;
514+
Kint::$cli_detection = false;
515+
516+
$this->expectOutputRegex('/<style {csp-style-nonce} class="kint-rich-style">/u');
517+
trace();
518+
}
485519
}

0 commit comments

Comments
 (0)