1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-03-15 11:50:01 +01:00

Fix tests

This commit is contained in:
Barry vd. Heuvel 2021-06-22 09:56:39 +02:00
parent d848222fd5
commit 87e627ad1a
3 changed files with 6 additions and 5 deletions

View File

@ -947,7 +947,7 @@ class JavascriptRenderer
}
foreach ($inlineJs as $content) {
$html .= sprintf('<script type="text/javascript" %s>%s</script>' . "\n", $nonce, $content);
$html .= sprintf('<script type="text/javascript"%s>%s</script>' . "\n", $nonce, $content);
}
foreach ($inlineHead as $content) {
@ -1045,9 +1045,9 @@ class JavascriptRenderer
$nonce = $this->getNonceAttribute();
if ($this->useRequireJs){
return "<script type=\"text/javascript\" {$nonce}>\nrequire(['debugbar'], function(PhpDebugBar){ $js });\n</script>\n";
return "<script type=\"text/javascript\"{$nonce}>\nrequire(['debugbar'], function(PhpDebugBar){ $js });\n</script>\n";
} else {
return "<script type=\"text/javascript\" {$nonce}>\n$js\n</script>\n";
return "<script type=\"text/javascript\"{$nonce}>\n$js\n</script>\n";
}
}
@ -1188,7 +1188,7 @@ class JavascriptRenderer
protected function getNonceAttribute()
{
if ($nonce = $this->getCspNonce()) {
return 'nonce="' . $nonce .'"';
return ' nonce="' . $nonce .'"';
}
return '';

View File

@ -27,6 +27,7 @@ class TimeDataCollectorTest extends DebugBarTestCase
public function testStartStopMeasure()
{
$this->c->startMeasure('foo', 'bar', 'baz');
usleep(1000);
$this->c->stopMeasure('foo', array('bar' => 'baz'));
$m = $this->c->getMeasures();
$this->assertCount(1, $m);

View File

@ -124,7 +124,7 @@ class JavascriptRendererTest extends DebugBarTestCase
{
$this->debugbar->addCollector(new \DebugBar\DataCollector\MessagesCollector());
$this->r->addControl('time', array('icon' => 'time', 'map' => 'time', 'default' => '"0s"'));
$expected = rtrim(file_get_contents(__DIR__ . '/full_init.html'));
$expected = str_replace("\r\n", "\n", rtrim(file_get_contents(__DIR__ . '/full_init.html')));
$this->assertStringStartsWith($expected, $this->r->render());
}