Skip to content

Commit

Permalink
feat: allow access to interactor's reader/writer instance
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Jul 7, 2018
1 parent 5cf1f74 commit 757a175
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/IO/Interactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public function __construct(string $input = null, string $output = null)
$this->writer = new Writer($output);
}

public function reader(): Reader
{
return $this->reader;
}

public function writer(): Writer
{
return $this->writer;
}

/**
* Confirms if user agrees to prompt as indicated by given text.
*
Expand Down
11 changes: 11 additions & 0 deletions tests/IO/InteractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Ahc\Cli\Test\Helper;

use Ahc\Cli\IO\Interactor;
use Ahc\Cli\Input\Reader;
use Ahc\Cli\Output\Writer;
use PHPUnit\Framework\TestCase;

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

public function test_components()
{
$i = $this->newInteractor();

// Useless test :)
$this->assertInstanceOf(Reader::class, $i->reader());
$this->assertInstanceOf(Writer::class, $i->writer());
}

public function test_confirm()
{
$i = $this->newInteractor('n');
Expand Down

0 comments on commit 757a175

Please sign in to comment.