Skip to content

Commit 5d0e21f

Browse files
committed
fix some test error
1 parent f660cd7 commit 5d0e21f

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ composer.lock
1818
.interactive_history
1919
*.bash
2020
*.zsh
21+
*.cache

Diff for: test/ApplicationTest.php

+13-10
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
use Inhere\Console\Console;
77
use Inhere\Console\IO\Input;
88
use Inhere\Console\IO\InputInterface;
9+
use Inhere\Console\Router;
910
use PHPUnit\Framework\TestCase;
1011

1112
class ApplicationTest extends TestCase
1213
{
13-
private function newApp(array $args = null)
14+
private function newApp(array $args = null): Application
1415
{
1516
$input = new Input($args);
1617

@@ -21,7 +22,7 @@ private function newApp(array $args = null)
2122
], $input);
2223
}
2324

24-
public function testApp()
25+
public function testApp(): void
2526
{
2627
$app = Console::newApp([
2728
'name' => 'Tests',
@@ -34,7 +35,7 @@ public function testApp()
3435
$this->assertInstanceOf(InputInterface::class, $app->getInput());
3536
}
3637

37-
public function testAddCommand()
38+
public function testAddCommand(): void
3839
{
3940
$app = $this->newApp();
4041

@@ -50,7 +51,7 @@ public function testAddCommand()
5051
$this->assertContains('test', $router->getCommandNames());
5152
}
5253

53-
public function testAddCommandError()
54+
public function testAddCommandError(): void
5455
{
5556
$app = $this->newApp();
5657

@@ -63,7 +64,7 @@ public function testAddCommandError()
6364
$app->addCommand('test', 'invalid');
6465
}
6566

66-
public function testRunCommand()
67+
public function testRunCommand(): void
6768
{
6869
$app = $this->newApp([
6970
'./app',
@@ -78,7 +79,7 @@ public function testRunCommand()
7879
$this->assertSame('hello', $ret);
7980
}
8081

81-
public function testAddController()
82+
public function testAddController(): void
8283
{
8384
$app = $this->newApp();
8485

@@ -89,11 +90,13 @@ public function testAddController()
8990
$this->assertTrue($app->getRouter()->isController('test'));
9091
$this->assertFalse($app->getRouter()->isCommand('test'));
9192
$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']);
9497
}
9598

96-
public function testAddControllerError()
99+
public function testAddControllerError(): void
97100
{
98101
$app = $this->newApp();
99102

@@ -106,7 +109,7 @@ public function testAddControllerError()
106109
$app->controller('test', 'invalid');
107110
}
108111

109-
public function testRunController()
112+
public function testRunController(): void
110113
{
111114
$app = $this->newApp([
112115
'./app',

Diff for: test/CommandTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
*/
1313
class CommandTest extends TestCase
1414
{
15-
public function testBasic()
15+
public function testBasic(): void
1616
{
1717
$c = new TestCommand(new Input(), new Output());
1818

1919
$this->assertSame('test1', $c::getName());
20-
$this->assertContains('desc', $c::getDescription());
20+
$this->assertStringContainsString('desc', $c::getDescription());
2121
}
22-
2322
}

Diff for: test/ControllerTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public function testBasic()
1717
$c = new TestController(new Input(), new Output());
1818

1919
$this->assertSame('test', $c::getName());
20-
$this->assertContains('desc', $c::getDescription());
20+
$this->assertStringContainsString('desc', $c::getDescription());
2121
}
22-
2322
}

0 commit comments

Comments
 (0)