Skip to content

Commit

Permalink
use OutputInterface instead of ConsoleOutputInterface (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Bragg authored Jun 16, 2017
1 parent 8dcfdd1 commit 64482a3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 48 deletions.
33 changes: 6 additions & 27 deletions src/DiffConsoleOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,21 @@
use Graze\DiffRenderer\Terminal\TerminalInterface;
use Graze\DiffRenderer\Wrap\Wrapper;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* This takes an array of lines to write to the console, does a different and only over-writes what has changed to the
* console
*/
class DiffConsoleOutput implements ConsoleOutputInterface
class DiffConsoleOutput implements OutputInterface
{
/** @var string[] */
private $buffer = [];
/** @var ConsoleDiff */
private $diff;
/** @var TerminalInterface */
private $terminal;
/** @var ConsoleOutputInterface */
/** @var OutputInterface */
private $output;
/** @var Wrapper */
private $wrapper;
Expand All @@ -44,12 +43,12 @@ class DiffConsoleOutput implements ConsoleOutputInterface
/**
* Constructor.
*
* @param ConsoleOutputInterface $output
* @param TerminalInterface $terminal
* @param Wrapper $wrapper
* @param OutputInterface $output
* @param TerminalInterface $terminal
* @param Wrapper $wrapper
*/
public function __construct(
ConsoleOutputInterface $output,
OutputInterface $output,
TerminalInterface $terminal = null,
Wrapper $wrapper = null
) {
Expand Down Expand Up @@ -138,26 +137,6 @@ private function buildOutput(array $diff, $newline = false)
return $buffer;
}

/**
* Gets the OutputInterface for errors.
*
* @return OutputInterface
*/
public function getErrorOutput()
{
return $this->output->getErrorOutput();
}

/**
* Sets the OutputInterface used for errors.
*
* @param OutputInterface $error
*/
public function setErrorOutput(OutputInterface $error)
{
$this->output->setErrorOutput($error);
}

/**
* Writes a message to the output and adds a newline at the end.
*
Expand Down
22 changes: 3 additions & 19 deletions tests/unit/DiffConsoleOutputPassthroughTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Graze\DiffRenderer\Test\TestCase;
use Mockery;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DiffConsoleOutputPassThroughTest extends TestCase
Expand All @@ -20,18 +19,13 @@ public function setUp()
{
parent::setUp();

$this->output = Mockery::mock(ConsoleOutputInterface::class);
$this->output = Mockery::mock(OutputInterface::class);
$this->diffOutput = new DiffConsoleOutput($this->output);
}

public function testGetErrorOutput()
public function testInstanceOf()
{
$output = Mockery::mock(OutputInterface::class);
$this->output->shouldReceive('getErrorOutput')
->with()
->andReturn($output);

$this->assertSame($output, $this->diffOutput->getErrorOutput());
$this->assertInstanceOf(OutputInterface::class, $this->diffOutput);
}

public function testGetVerbosity()
Expand Down Expand Up @@ -116,16 +110,6 @@ public function testSetDecorated()
$this->diffOutput->setDecorated(true);
}

public function testSetErrorOutput()
{
$error = Mockery::mock(OutputInterface::class);
$this->output->shouldReceive('setErrorOutput')
->with($error)
->once();

$this->diffOutput->setErrorOutput($error);
}

public function testSetFormatter()
{
$formatter = Mockery::mock(OutputFormatterInterface::class);
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/DiffConsoleOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Graze\DiffRenderer\Test\TestCase;
use Graze\DiffRenderer\Wrap\Wrapper;
use Mockery;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;

class DiffConsoleOutputTest extends TestCase
{
Expand All @@ -36,7 +36,7 @@ class DiffConsoleOutputTest extends TestCase

public function setUp()
{
$this->output = Mockery::mock(ConsoleOutput::class);
$this->output = Mockery::mock(OutputInterface::class);
$this->wrapper = Mockery::mock(Wrapper::class)->makePartial();
$this->dimensions = Mockery::mock(DimensionsInterface::class);
$this->terminal = new Terminal(null, $this->dimensions);
Expand Down

0 comments on commit 64482a3

Please sign in to comment.