Skip to content

Commit 757a175

Browse files
committed
feat: allow access to interactor's reader/writer instance
1 parent 5cf1f74 commit 757a175

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/IO/Interactor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ public function __construct(string $input = null, string $output = null)
3030
$this->writer = new Writer($output);
3131
}
3232

33+
public function reader(): Reader
34+
{
35+
return $this->reader;
36+
}
37+
38+
public function writer(): Writer
39+
{
40+
return $this->writer;
41+
}
42+
3343
/**
3444
* Confirms if user agrees to prompt as indicated by given text.
3545
*

tests/IO/InteractorTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Ahc\Cli\Test\Helper;
44

55
use Ahc\Cli\IO\Interactor;
6+
use Ahc\Cli\Input\Reader;
7+
use Ahc\Cli\Output\Writer;
68
use PHPUnit\Framework\TestCase;
79

810
class InteractorTest extends TestCase
@@ -22,6 +24,15 @@ public function tearDown()
2224
unlink(static::$ou);
2325
}
2426

27+
public function test_components()
28+
{
29+
$i = $this->newInteractor();
30+
31+
// Useless test :)
32+
$this->assertInstanceOf(Reader::class, $i->reader());
33+
$this->assertInstanceOf(Writer::class, $i->writer());
34+
}
35+
2536
public function test_confirm()
2637
{
2738
$i = $this->newInteractor('n');

0 commit comments

Comments
 (0)