test: add tests for Kint with CSP

This commit is contained in:
kenjis 2021-12-27 11:37:44 +09:00
parent 70625366ae
commit 9c379088e8
No known key found for this signature in database
GPG Key ID: BD254878922AF198

View File

@ -29,6 +29,7 @@ use Config\App;
use Config\Logger;
use Config\Modules;
use InvalidArgumentException;
use Kint;
use stdClass;
use Tests\Support\Models\JobModel;
@ -482,4 +483,37 @@ final class CommonFunctionsTest extends CIUnitTestCase
$this->assertIsBool(is_cli());
$this->assertTrue(is_cli());
}
public function testDWithCSP()
{
/** @var App $config */
$config = config(App::class);
$CSPEnabled = $config->CSPEnabled;
$cliDetection = Kint::$cli_detection;
$config->CSPEnabled = true;
Kint::$cli_detection = false;
$this->expectOutputRegex('/<script {csp-script-nonce} class="kint-rich-script">/u');
d('string');
// Restore settings
$config->CSPEnabled = $CSPEnabled;
Kint::$cli_detection = $cliDetection;
}
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testTraceWithCSP()
{
/** @var App $config */
$config = config(App::class);
$config->CSPEnabled = true;
Kint::$cli_detection = false;
$this->expectOutputRegex('/<style {csp-style-nonce} class="kint-rich-style">/u');
trace();
}
}