Add void return to method in tests. (#20602)

This commit is contained in:
Wilmer Arambula
2025-10-14 06:37:35 -03:00
committed by GitHub
parent 30824c5dcf
commit d71f7309ae
249 changed files with 2749 additions and 2538 deletions

View File

@@ -8,6 +8,9 @@
namespace yiiunit\framework\web;
use Exception;
use yii\BaseYii;
use yii\web\Application;
use Yii;
use yii\web\NotFoundHttpException;
use yii\web\View;
@@ -30,7 +33,7 @@ class ErrorHandlerTest extends TestCase
]);
}
public function testCorrectResponseCodeInErrorView()
public function testCorrectResponseCodeInErrorView(): void
{
/** @var ErrorHandler $handler */
$handler = Yii::$app->getErrorHandler();
@@ -43,7 +46,7 @@ Message: This message is displayed to end user
Exception: yii\web\NotFoundHttpException', $out);
}
public function testFormatRaw()
public function testFormatRaw(): void
{
Yii::$app->response->format = yii\web\Response::FORMAT_RAW;
@@ -51,7 +54,7 @@ Exception: yii\web\NotFoundHttpException', $out);
$handler = Yii::$app->getErrorHandler();
ob_start(); // suppress response output
$this->invokeMethod($handler, 'renderException', [new \Exception('Test Exception')]);
$this->invokeMethod($handler, 'renderException', [new Exception('Test Exception')]);
$out = ob_get_clean();
$this->assertStringContainsString('Test Exception', $out);
@@ -63,7 +66,7 @@ Exception: yii\web\NotFoundHttpException', $out);
);
}
public function testFormatXml()
public function testFormatXml(): void
{
Yii::$app->response->format = yii\web\Response::FORMAT_XML;
@@ -71,7 +74,7 @@ Exception: yii\web\NotFoundHttpException', $out);
$handler = Yii::$app->getErrorHandler();
ob_start(); // suppress response output
$this->invokeMethod($handler, 'renderException', [new \Exception('Test Exception')]);
$this->invokeMethod($handler, 'renderException', [new Exception('Test Exception')]);
$out = ob_get_clean();
$this->assertStringContainsString('Test Exception', $out);
@@ -89,19 +92,19 @@ Exception: yii\web\NotFoundHttpException', $out);
$this->assertArrayHasKey('line', $outArray);
}
public function testClearAssetFilesInErrorView()
public function testClearAssetFilesInErrorView(): void
{
Yii::$app->getView()->registerJsFile('somefile.js');
/** @var ErrorHandler $handler */
$handler = Yii::$app->getErrorHandler();
ob_start(); // suppress response output
$this->invokeMethod($handler, 'renderException', [new \Exception('Some Exception')]);
$this->invokeMethod($handler, 'renderException', [new Exception('Some Exception')]);
ob_get_clean();
$out = Yii::$app->response->data;
$this->assertEquals("Exception View\n", $out);
}
public function testClearAssetFilesInErrorActionView()
public function testClearAssetFilesInErrorActionView(): void
{
Yii::$app->getErrorHandler()->errorAction = 'test/error';
Yii::$app->getView()->registerJs("alert('hide me')", View::POS_END);
@@ -115,13 +118,13 @@ Exception: yii\web\NotFoundHttpException', $out);
$this->assertStringNotContainsString('<script', $out);
}
public function testRenderCallStackItem()
public function testRenderCallStackItem(): void
{
$handler = Yii::$app->getErrorHandler();
$handler->traceLine = '<a href="netbeans://open?file={file}&line={line}">{html}</a>';
$file = \yii\BaseYii::getAlias('@yii/web/Application.php');
$file = BaseYii::getAlias('@yii/web/Application.php');
$out = $handler->renderCallStackItem($file, 63, \yii\web\Application::className(), null, null, null);
$out = $handler->renderCallStackItem($file, 63, Application::className(), null, null, null);
$this->assertStringContainsString('<a href="netbeans://open?file=' . $file . '&line=63">', $out);
}
@@ -159,14 +162,14 @@ Exception: yii\web\NotFoundHttpException', $out);
/**
* @dataProvider dataHtmlEncode
*/
public function testHtmlEncode($text, $expected)
public function testHtmlEncode($text, $expected): void
{
$handler = Yii::$app->getErrorHandler();
$this->assertSame($expected, $handler->htmlEncode($text));
}
public function testHtmlEncodeWithUnicodeSequence()
public function testHtmlEncodeWithUnicodeSequence(): void
{
$handler = Yii::$app->getErrorHandler();