mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
test: add tests for Kint with CSP
This commit is contained in:
parent
70625366ae
commit
9c379088e8
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user