Skip to content

Commit 66cdbf5

Browse files
committed
Add Command::{get,set}Console methods
1 parent 9786c52 commit 66cdbf5

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/Command.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,29 @@ public function __construct(Console $console)
6060
*/
6161
abstract public function run() : void;
6262

63+
/**
64+
* Get console instance.
65+
*
66+
* @return Console
67+
*/
68+
public function getConsole() : Console
69+
{
70+
return $this->console;
71+
}
72+
73+
/**
74+
* Set console instance.
75+
*
76+
* @param Console $console
77+
*
78+
* @return static
79+
*/
80+
public function setConsole(Console $console) : static
81+
{
82+
$this->console = $console;
83+
return $this;
84+
}
85+
6386
/**
6487
* Get command name.
6588
*

tests/CommandTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ protected function setUp() : void
2121
$this->command = new CommandMock(new Console());
2222
}
2323

24+
public function testConsole() : void
25+
{
26+
self::assertInstanceOf(Console::class, $this->command->getConsole());
27+
$console = new Console();
28+
$this->command->setConsole($console);
29+
self::assertSame($console, $this->command->getConsole());
30+
}
31+
2432
public function testName() : void
2533
{
2634
self::assertSame('test', $this->command->getName());

0 commit comments

Comments
 (0)