Skip to content

Commit

Permalink
test for the style custom options
Browse files Browse the repository at this point in the history
  • Loading branch information
nzwz committed Jan 20, 2025
1 parent d146307 commit 8f2be61
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/framework/helpers/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ public function testStyle()
$this->assertEquals("<style type=\"text/less\">{$content}</style>", Html::style($content, ['type' => 'text/less']));
}

public function testStyleCustomAttribute()
{
$nonce = Yii::$app->security->generateRandomString();
$this->mockApplication([
'components' => [
'view' => [
'class' => 'yii\web\View',
'styleOptions' => ['nonce' => $nonce],
],
],
]);
$content = 'a <>';
$this->assertEquals("<style nonce=\"{$nonce}\">{$content}</style>", Html::style($content));
}

public function testScript()
{
$content = 'a <>';
Expand Down

0 comments on commit 8f2be61

Please sign in to comment.