Skip to content

Commit 980db8a

Browse files
soyukateohhanhui
authored andcommitted
Fix tests
1 parent 77f16b5 commit 980db8a

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

phpstan.neon.dist

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ parameters:
125125
path: %currentWorkingDirectory%/src/Action/ExceptionAction.php
126126
- '#Call to method get(Class|Headers|StatusCode)\(\) on an unknown class Symfony\\Component\\ErrorHandler\\Exception\\FlattenException\.#'
127127
-
128-
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and 'getException' will always evaluate to false\\.#"
129-
path: %currentWorkingDirectory%/tests/Bridge/Symfony/Validator/EventListener/ValidationExceptionListenerTest.php
128+
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and 'getThrowable' will always evaluate to false\\.#"
129+
paths:
130+
- %currentWorkingDirectory%/tests/Bridge/Symfony/Validator/EventListener/ValidationExceptionListenerTest.php
131+
- %currentWorkingDirectory%/tests/EventListener/ExceptionListenerTest.php
130132
-
131133
message: '#Instanceof between bool\|float\|int|null and ArrayObject will always evaluate to false\.#'
132134
paths:

tests/Bridge/Symfony/Validator/EventListener/ValidationExceptionListenerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class ValidationExceptionListenerTest extends TestCase
3131
public function testNotValidationException()
3232
{
3333
$eventProphecy = $this->prophesize(ExceptionEvent::class);
34-
if (method_exists(ExceptionEvent::class, 'getException')) {
35-
$eventProphecy->getException()->willReturn(new \Exception())->shouldBeCalled();
36-
} else {
34+
if (method_exists(ExceptionEvent::class, 'getThrowable')) {
3735
$eventProphecy->getThrowable()->willReturn(new \Exception())->shouldBeCalled();
36+
} else {
37+
$eventProphecy->getException()->willReturn(new \Exception())->shouldBeCalled();
3838
}
3939
$eventProphecy->setResponse()->shouldNotBeCalled();
4040

@@ -50,10 +50,10 @@ public function testValidationException()
5050
$list = new ConstraintViolationList([]);
5151

5252
$eventProphecy = $this->prophesize(ExceptionEvent::class);
53-
if (method_exists(ExceptionEvent::class, 'getException')) {
54-
$eventProphecy->getException()->willReturn(new ValidationException($list))->shouldBeCalled();
55-
} else {
53+
if (method_exists(ExceptionEvent::class, 'getThrowable')) {
5654
$eventProphecy->getThrowable()->willReturn(new ValidationException($list))->shouldBeCalled();
55+
} else {
56+
$eventProphecy->getException()->willReturn(new ValidationException($list))->shouldBeCalled();
5757
}
5858
$eventProphecy->getRequest()->willReturn(new Request())->shouldBeCalled();
5959
$eventProphecy->setResponse(Argument::allOf(

tests/EventListener/ExceptionListenerTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ public function testOnKernelException(Request $request)
3636

3737
$eventProphecy = $this->prophesize(ExceptionEvent::class);
3838
$eventProphecy->getRequest()->willReturn($request);
39-
$eventProphecy->getException()->willReturn(new \Exception());
39+
if (method_exists(ExceptionEvent::class, 'getThrowable')) {
40+
$eventProphecy->getThrowable()->willReturn(new \Exception());
41+
} else {
42+
$eventProphecy->getException()->willReturn(new \Exception());
43+
}
4044
$eventProphecy->getKernel()->willReturn($kernel);
4145
$eventProphecy->setResponse(Argument::type(Response::class))->shouldBeCalled();
4246

0 commit comments

Comments
 (0)