Skip to content

Commit 9d69938

Browse files
committed
Fix tests ControllerTest.php.
1 parent aca7827 commit 9d69938

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

tests/framework/console/ControllerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@
88
namespace yiiunit\framework\console;
99

1010
use RuntimeException;
11-
use yii\console\Exception;
12-
use yiiunit\framework\console\stubs\DummyService;
1311
use Yii;
1412
use yii\base\InlineAction;
1513
use yii\base\Module;
1614
use yii\console\Application;
15+
use yii\console\Exception;
1716
use yii\console\Request;
17+
use yii\console\Response;
1818
use yii\helpers\Console;
19+
use yiiunit\framework\console\stubs\DummyService;
1920
use yiiunit\TestCase;
2021

2122
/**
2223
* @group console
2324
*/
2425
class ControllerTest extends TestCase
2526
{
26-
private ?\yiiunit\framework\console\FakePhp71Controller $controller = null;
27+
private FakePhp71Controller|null $controller = null;
2728

2829
protected function setUp(): void
2930
{
@@ -92,10 +93,9 @@ public function testBindActionParams(): void
9293

9394
$params = ['avaliable'];
9495
$message = Yii::t('yii', 'Missing required arguments: {params}', ['params' => implode(', ', ['missing'])]);
95-
$this->expectException('yii\console\Exception');
96+
$this->expectException(Exception::class);
9697
$this->expectExceptionMessage($message);
9798
$result = $controller->runAction('aksi3', $params);
98-
9999
}
100100

101101
public function testNullableInjectedActionParams(): void
@@ -127,7 +127,7 @@ public function testInjectionContainerException(): void
127127
$params = ['between' => 'test', 'after' => 'another', 'before' => 'test'];
128128
\Yii::$container->set(DummyService::class, function(): never { throw new \RuntimeException('uh oh'); });
129129

130-
$this->expectException((new RuntimeException())::class);
130+
$this->expectException(RuntimeException::class);
131131
$this->expectExceptionMessage('uh oh');
132132
$this->controller->bindActionParams($injectionAction, $params);
133133
}
@@ -144,7 +144,7 @@ public function testUnknownInjection(): void
144144
$injectionAction = new InlineAction('injection', $this->controller, 'actionInjection');
145145
$params = ['between' => 'test', 'after' => 'another', 'before' => 'test'];
146146
\Yii::$container->clear(DummyService::class);
147-
$this->expectException((new Exception())::class);
147+
$this->expectException(Exception::class);
148148
$this->expectExceptionMessage('Could not load required service: dummyService');
149149
$this->controller->bindActionParams($injectionAction, $params);
150150
}
@@ -198,7 +198,7 @@ public function assertResponseStatus($status, $response): void
198198
$this->assertSame($status, $response->exitStatus);
199199
}
200200

201-
public function runRequest($route, $args = 0)
201+
public function runRequest($route, $args = 0): Response
202202
{
203203
$request = new Request();
204204
$request->setParams(func_get_args());

tests/framework/console/FakePhp71Controller.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@
1414

1515
class FakePhp71Controller extends Controller
1616
{
17-
public function actionInjection($before, Request $request, $between, DummyService $dummyService, $after, Post $post = null): void
18-
{
19-
17+
public function actionInjection(
18+
$before,
19+
Request $request,
20+
$between,
21+
DummyService $dummyService,
22+
Post $post = null,
23+
$after
24+
): void {
2025
}
2126

2227
public function actionNullableInjection(?Request $request, ?Post $post): void

0 commit comments

Comments
 (0)