-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Yii2 ErrorHandler can not process when throw Error (#106) #107
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,16 @@ public function actionEnd() | |
\Yii::$app->end(); | ||
} | ||
|
||
public function actionTypeError() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a return type to any function you touch! |
||
{ | ||
$testClass = new class { | ||
public ?int $intType = 0; | ||
}; | ||
|
||
$testClass->intType = 'string'; | ||
|
||
return $testClass->intType; | ||
} | ||
|
||
/** | ||
* @param Action $action | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,19 +35,18 @@ public function testFormSubmit2(FunctionalTester $I) | |
|
||
public function testException(FunctionalTester $I) | ||
{ | ||
$I->expectThrowable(new \Exception('This is not an HttpException'), function() use ($I) { | ||
$I->amOnRoute('/site/exception'); | ||
}); | ||
$I->assertInstanceOf(Application::class, \Yii::$app); | ||
$I->amOnRoute('/site/exception'); | ||
$I->seeResponseCodeIsServerError(); | ||
$content = $I->grabPageSource(); | ||
$I->assertStringStartsWith("<pre>Exception 'Exception' with message 'This is not an HttpException'", $content); | ||
} | ||
Comment on lines
36
to
42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a return type to any function you touch! |
||
|
||
public function testExceptionInBeforeRequest(FunctionalTester $I) | ||
public function testTypeError(FunctionalTester $I) | ||
{ | ||
$e = new \Exception('This is not an HttpException'); | ||
\Yii::$app->params['throw'] = $e; | ||
$I->expectThrowable($e, function() use ($I) { | ||
$I->amOnRoute('/site/exception'); | ||
}); | ||
$I->amOnRoute('/site/type-error'); | ||
$I->seeResponseCodeIsServerError(); | ||
$content = $I->grabPageSource(); | ||
$I->assertStringStartsWith('<pre>Exception 'TypeError' with message 'Cannot assign string to property', $content); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to check the string contains |
||
} | ||
Comment on lines
+44
to
50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a return type to any function you touch! |
||
|
||
public function testExitException(FunctionalTester $I) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it necessary to remove this logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, see my comment in the issue itself. I am currently doubting whether the issue is valid at all.