Browse Source

Recreate test based on naming & consistency with previous test (#14557)

tags/3.0.0-alpha1
Boudewijn Vahrmeijer 7 years ago committed by Alexander Makarov
parent
commit
31a405bf80
  1. 21
      tests/framework/helpers/HtmlTest.php

21
tests/framework/helpers/HtmlTest.php

@ -138,13 +138,22 @@ class HtmlTest extends TestCase
$this->assertStringMatchesFormat($pattern, $actual);
}
public function testCsrfMetaTagsEnableCsrfValidationWithoutCookieValidationKey()
public function testCsrfMetaTagsEnableCsrfValidation_WithoutCookieValidationKey()
{
$request = $this->getMockBuilder(\yii\web\Request::class)
->setMethods(['enableCsrfValidation'])->getMock();
$request->method('enableCsrfValidation')->willReturn(true);
Yii::$app->set('request', $request);
$pattern = '<meta name="csrf-param" content="_csrf">%A<meta name="csrf-token">';
$this->mockApplication([
'components' => [
'request' => [
'class' => 'yii\web\Request',
'enableCsrfValidation' => true,
'enableCookieValidation' => false,
'cookieValidationKey' => '',
],
'response' => [
'class' => 'yii\web\Response',
],
],
]);
$pattern = '<meta name="csrf-param" content="_csrf">%A<meta name="csrf-token" content="%s">';
$actual = Html::csrfMetaTags();
$this->assertStringMatchesFormat($pattern, $actual);
}

Loading…
Cancel
Save