Skip to content

Commit b12bbde

Browse files
committed
Test CSP Nonce
1 parent 87e627a commit b12bbde

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/DebugBar/Tests/JavascriptRendererTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
class JavascriptRendererTest extends DebugBarTestCase
1010
{
11+
/** @var JavascriptRenderer */
12+
protected $r;
13+
1114
public function setUp(): void
1215
{
1316
parent::setUp();
@@ -137,6 +140,13 @@ public function testRenderConstructorOnly()
137140
$this->assertStringStartsWith("<script type=\"text/javascript\">\nvar foovar = new Foobar();\nfoovar.addDataSet(", $this->r->render());
138141
}
139142

143+
public function testRenderConstructorWithNonce()
144+
{
145+
$this->r->setInitialization(JavascriptRenderer::INITIALIZE_CONSTRUCTOR);
146+
$this->r->setCspNonce('mynonce');
147+
$this->assertStringStartsWith("<script type=\"text/javascript\" nonce=\"mynonce\">\nvar phpdebugbar = new PhpDebugBar.DebugBar();", $this->r->render());
148+
}
149+
140150
public function testJQueryNoConflictAutoDisabling()
141151
{
142152
$this->assertTrue($this->r->isJqueryNoConflictEnabled());

0 commit comments

Comments
 (0)