2
2
3
3
declare (strict_types=1 );
4
4
5
+ namespace Yiisoft \Middleware \Dispatcher \Tests ;
6
+
5
7
use PHPUnit \Framework \TestCase ;
6
8
use Psr \Container \ContainerInterface ;
7
9
use Psr \Http \Server \MiddlewareInterface ;
10
+ use stdClass ;
11
+ use Yiisoft \Middleware \Dispatcher \InvalidMiddlewareDefinitionException ;
8
12
use Yiisoft \Middleware \Dispatcher \MiddlewareFactory ;
9
13
use Yiisoft \Middleware \Dispatcher \MiddlewareFactoryInterface ;
10
14
use Yiisoft \Middleware \Dispatcher \Tests \Support \Container ;
@@ -29,39 +33,39 @@ public function testCreateFromArray(): void
29
33
30
34
public function testInvalidMiddleware (): void
31
35
{
32
- $ this ->expectException (\InvalidArgumentException ::class);
33
- $ this ->getMiddlewareFactory ()->create (new \ stdClass ());
36
+ $ this ->expectException (InvalidMiddlewareDefinitionException ::class);
37
+ $ this ->getMiddlewareFactory ()->create (new stdClass ());
34
38
}
35
39
36
40
public function testInvalidMiddlewareAddWrongString (): void
37
41
{
38
- $ this ->expectException (\InvalidArgumentException ::class);
42
+ $ this ->expectException (InvalidMiddlewareDefinitionException ::class);
39
43
$ this ->getMiddlewareFactory ()->create ('test ' );
40
44
}
41
45
42
46
public function testInvalidMiddlewareAddWrongStringClass (): void
43
47
{
44
- $ this ->expectException (\InvalidArgumentException ::class);
48
+ $ this ->expectException (InvalidMiddlewareDefinitionException ::class);
45
49
$ this ->expectExceptionMessage ('Parameter should be either PSR middleware class name or a callable. ' );
46
50
$ this ->getMiddlewareFactory ()->create (TestController::class);
47
51
}
48
52
49
53
public function testInvalidMiddlewareAddWrongArraySize (): void
50
54
{
51
- $ this ->expectException (\InvalidArgumentException ::class);
55
+ $ this ->expectException (InvalidMiddlewareDefinitionException ::class);
52
56
$ this ->getMiddlewareFactory ()->create (['test ' ]);
53
57
}
54
58
55
59
public function testInvalidMiddlewareAddWrongArrayClass (): void
56
60
{
57
- $ this ->expectException (\InvalidArgumentException ::class);
61
+ $ this ->expectException (InvalidMiddlewareDefinitionException ::class);
58
62
$ this ->getMiddlewareFactory ()->create (['class ' , 'test ' ]);
59
63
}
60
64
61
65
public function testInvalidMiddlewareAddWrongArrayType (): void
62
66
{
63
- $ this ->expectException (\InvalidArgumentException ::class);
64
- $ this ->getMiddlewareFactory ()->create (['class ' => \ Yiisoft \ Router \ Tests \ Support \ TestController::class, 'index ' ]);
67
+ $ this ->expectException (InvalidMiddlewareDefinitionException ::class);
68
+ $ this ->getMiddlewareFactory ()->create (['class ' => TestController::class, 'index ' ]);
65
69
}
66
70
67
71
private function getMiddlewareFactory (ContainerInterface $ container = null ): MiddlewareFactoryInterface
0 commit comments