Skip to content

Commit f1764a2

Browse files
authored
Merge pull request #81 from sunrise-php/release/v2.11.1
v2.11.1
2 parents fc35ef3 + 1913417 commit f1764a2

File tree

2 files changed

+48
-15
lines changed

2 files changed

+48
-15
lines changed

src/Command/RouteListCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public function __construct(?Router $router = null)
6666
{
6767
parent::__construct();
6868

69+
$this->setName(static::$defaultName);
70+
$this->setDescription(static::$defaultDescription);
71+
6972
$this->router = $router;
7073
}
7174

tests/Command/RouteListCommandTest.php

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,43 +32,73 @@ public function testRun() : void
3232
]);
3333

3434
$command = new RouteListCommand($router);
35-
$commandTester = new CommandTester($command);
3635

37-
$exitCode = $commandTester->execute([]);
36+
$this->assertSame('router:route-list', $command->getName());
37+
38+
$commandTester = new CommandTester($command);
3839

39-
$this->assertSame(0, $exitCode);
40+
$this->assertSame(0, $commandTester->execute([]));
4041
}
4142

4243
/**
4344
* @return void
4445
*/
45-
public function testRunWithoutRouter() : void
46+
public function testRunInheritedCommand() : void
4647
{
47-
$command = new RouteListCommand();
48-
$commandTester = new CommandTester($command);
48+
$command = new class extends RouteListCommand
49+
{
50+
public function __construct()
51+
{
52+
parent::__construct(null);
53+
}
4954

50-
$this->expectException(RuntimeException::class);
55+
protected function getRouter() : Router
56+
{
57+
return new Router();
58+
}
59+
};
5160

52-
$commandTester->execute([]);
61+
$this->assertSame('router:route-list', $command->getName());
62+
63+
$commandTester = new CommandTester($command);
64+
65+
$this->assertSame(0, $commandTester->execute([]));
5366
}
5467

5568
/**
5669
* @return void
5770
*/
58-
public function testRunInheritedCommand() : void
71+
public function testRunRenamedCommand() : void
5972
{
60-
$userCommand = new class extends RouteListCommand
73+
$command = new class extends RouteListCommand
6174
{
62-
protected function getRouter() : Router
75+
protected static $defaultName = 'foo';
76+
protected static $defaultDescription = 'bar';
77+
78+
public function __construct()
6379
{
64-
return new Router();
80+
parent::__construct(new Router());
6581
}
6682
};
6783

68-
$commandTester = new CommandTester($userCommand);
84+
$this->assertSame('foo', $command->getName());
85+
$this->assertSame('bar', $command->getDescription());
6986

70-
$exitCode = $commandTester->execute([]);
87+
$commandTester = new CommandTester($command);
88+
89+
$this->assertSame(0, $commandTester->execute([]));
90+
}
7191

72-
$this->assertSame(0, $exitCode);
92+
/**
93+
* @return void
94+
*/
95+
public function testRunWithoutRouter() : void
96+
{
97+
$command = new RouteListCommand();
98+
$commandTester = new CommandTester($command);
99+
100+
$this->expectException(RuntimeException::class);
101+
102+
$commandTester->execute([]);
73103
}
74104
}

0 commit comments

Comments
 (0)