Skip to content

Commit 6d9b18c

Browse files
committed
Test inactive command
1 parent 2e47a6e commit 6d9b18c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tests/ConsoleTest.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,25 @@ public function testDefaultCommands() : void
144144

145145
public function testCommands() : void
146146
{
147-
$command = new class($this->console) extends CommandMock {
148-
protected string $name = 'test';
149-
protected bool $active = false;
150-
};
151-
$this->console->addCommand($command);
152-
self::assertNull($this->console->getCommand('test'));
153147
$command = new CommandMock($this->console);
154148
$this->console->addCommands([$command]);
155149
self::assertNotEmpty($this->console->getCommands());
156150
self::assertInstanceOf(Command::class, $this->console->getCommand('test'));
157151
}
158152

153+
public function testInactiveCommand() : void
154+
{
155+
$inactiveCommand = new class($this->console) extends CommandMock {
156+
protected string $name = 'foo';
157+
protected bool $active = false;
158+
};
159+
$this->console->addCommand($inactiveCommand);
160+
self::assertNull($this->console->getCommand('foo'));
161+
foreach ($this->console->getCommands() as $command) {
162+
self::assertNotSame($inactiveCommand, $command);
163+
}
164+
}
165+
159166
public function testRemoveCommands() : void
160167
{
161168
self::assertNotNull($this->console->getCommand('about'));

0 commit comments

Comments
 (0)