88namespace yiiunit \framework \console ;
99
1010use RuntimeException ;
11- use yii \console \Exception ;
12- use yiiunit \framework \console \stubs \DummyService ;
1311use Yii ;
1412use yii \base \InlineAction ;
1513use yii \base \Module ;
1614use yii \console \Application ;
15+ use yii \console \Exception ;
1716use yii \console \Request ;
17+ use yii \console \Response ;
1818use yii \helpers \Console ;
19+ use yiiunit \framework \console \stubs \DummyService ;
1920use yiiunit \TestCase ;
2021
2122/**
2223 * @group console
2324 */
2425class 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 ());
0 commit comments