6
6
use Inhere \Console \Console ;
7
7
use Inhere \Console \IO \Input ;
8
8
use Inhere \Console \IO \InputInterface ;
9
+ use Inhere \Console \Router ;
9
10
use PHPUnit \Framework \TestCase ;
10
11
11
12
class ApplicationTest extends TestCase
12
13
{
13
- private function newApp (array $ args = null )
14
+ private function newApp (array $ args = null ): Application
14
15
{
15
16
$ input = new Input ($ args );
16
17
@@ -21,7 +22,7 @@ private function newApp(array $args = null)
21
22
], $ input );
22
23
}
23
24
24
- public function testApp ()
25
+ public function testApp (): void
25
26
{
26
27
$ app = Console::newApp ([
27
28
'name ' => 'Tests ' ,
@@ -34,7 +35,7 @@ public function testApp()
34
35
$ this ->assertInstanceOf (InputInterface::class, $ app ->getInput ());
35
36
}
36
37
37
- public function testAddCommand ()
38
+ public function testAddCommand (): void
38
39
{
39
40
$ app = $ this ->newApp ();
40
41
@@ -50,7 +51,7 @@ public function testAddCommand()
50
51
$ this ->assertContains ('test ' , $ router ->getCommandNames ());
51
52
}
52
53
53
- public function testAddCommandError ()
54
+ public function testAddCommandError (): void
54
55
{
55
56
$ app = $ this ->newApp ();
56
57
@@ -63,7 +64,7 @@ public function testAddCommandError()
63
64
$ app ->addCommand ('test ' , 'invalid ' );
64
65
}
65
66
66
- public function testRunCommand ()
67
+ public function testRunCommand (): void
67
68
{
68
69
$ app = $ this ->newApp ([
69
70
'./app ' ,
@@ -78,7 +79,7 @@ public function testRunCommand()
78
79
$ this ->assertSame ('hello ' , $ ret );
79
80
}
80
81
81
- public function testAddController ()
82
+ public function testAddController (): void
82
83
{
83
84
$ app = $ this ->newApp ();
84
85
@@ -89,11 +90,13 @@ public function testAddController()
89
90
$ this ->assertTrue ($ app ->getRouter ()->isController ('test ' ));
90
91
$ this ->assertFalse ($ app ->getRouter ()->isCommand ('test ' ));
91
92
$ this ->assertArrayHasKey ('test ' , $ router ->getControllers ());
92
- $ this ->assertContains ('test ' , $ router ->getControllerNames ());
93
- $ this ->assertSame (TestController::class, $ router ->getControllers ()['test ' ]);
93
+
94
+ $ group = $ router ->getControllers ()['test ' ];
95
+ $ this ->assertSame (TestController::class, $ group ['handler ' ]);
96
+ $ this ->assertSame (Router::TYPE_GROUP , $ group ['type ' ]);
94
97
}
95
98
96
- public function testAddControllerError ()
99
+ public function testAddControllerError (): void
97
100
{
98
101
$ app = $ this ->newApp ();
99
102
@@ -106,7 +109,7 @@ public function testAddControllerError()
106
109
$ app ->controller ('test ' , 'invalid ' );
107
110
}
108
111
109
- public function testRunController ()
112
+ public function testRunController (): void
110
113
{
111
114
$ app = $ this ->newApp ([
112
115
'./app ' ,
0 commit comments