|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Graze\DiffRenderer\Test\Unit; |
|
4
|
|
|
|
|
5
|
|
|
use Graze\DiffRenderer\DiffConsoleOutput; |
|
6
|
|
|
use Graze\DiffRenderer\Terminal\TerminalInterface; |
|
7
|
|
|
use Graze\DiffRenderer\Test\TestCase; |
|
8
|
|
|
use Mockery; |
|
9
|
|
|
use Symfony\Component\Console\Formatter\OutputFormatterInterface; |
|
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
11
|
|
|
|
|
12
|
|
|
class DiffConsoleOutputPassThroughTest extends TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
/** @var DiffConsoleOutput */ |
|
15
|
|
|
private $diffOutput; |
|
16
|
|
|
/** @var mixed */ |
|
17
|
|
|
private $output; |
|
18
|
|
|
/** @var mixed */ |
|
19
|
|
|
private $terminal; |
|
20
|
|
|
|
|
21
|
|
|
public function setUp() |
|
22
|
|
|
{ |
|
23
|
|
|
parent::setUp(); |
|
24
|
|
|
|
|
25
|
|
|
$this->output = Mockery::mock(OutputInterface::class); |
|
26
|
|
|
$this->diffOutput = new DiffConsoleOutput($this->output, $this->terminal); |
|
|
|
|
|
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function testInstanceOf() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->assertInstanceOf(OutputInterface::class, $this->diffOutput); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testGetVerbosity() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->output->shouldReceive('getVerbosity') |
|
37
|
|
|
->with() |
|
38
|
|
|
->andReturn(OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
39
|
|
|
|
|
40
|
|
|
$this->assertEquals(OutputInterface::VERBOSITY_VERY_VERBOSE, $this->diffOutput->getVerbosity()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testGetFormatter() |
|
44
|
|
|
{ |
|
45
|
|
|
$formatter = Mockery::mock(OutputFormatterInterface::class); |
|
46
|
|
|
$this->output->shouldReceive('getFormatter') |
|
47
|
|
|
->with() |
|
48
|
|
|
->andReturn($formatter); |
|
49
|
|
|
|
|
50
|
|
|
$this->assertEquals($formatter, $this->diffOutput->getFormatter()); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testIsDebug() |
|
54
|
|
|
{ |
|
55
|
|
|
$this->output->shouldReceive('isDebug') |
|
56
|
|
|
->with() |
|
57
|
|
|
->andReturn(false); |
|
58
|
|
|
|
|
59
|
|
|
$this->assertEquals(false, $this->diffOutput->isDebug()); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function testIsDecorated() |
|
63
|
|
|
{ |
|
64
|
|
|
$this->output->shouldReceive('isDecorated') |
|
65
|
|
|
->with() |
|
66
|
|
|
->andReturn(true); |
|
67
|
|
|
|
|
68
|
|
|
$this->assertEquals(true, $this->diffOutput->isDecorated()); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function testIsQuiet() |
|
72
|
|
|
{ |
|
73
|
|
|
$this->output->shouldReceive('isQuiet') |
|
74
|
|
|
->with() |
|
75
|
|
|
->andReturn(false); |
|
76
|
|
|
|
|
77
|
|
|
$this->assertEquals(false, $this->diffOutput->isQuiet()); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function testIsVerbose() |
|
81
|
|
|
{ |
|
82
|
|
|
$this->output->shouldReceive('isVerbose') |
|
83
|
|
|
->with() |
|
84
|
|
|
->andReturn(true); |
|
85
|
|
|
|
|
86
|
|
|
$this->assertEquals(true, $this->diffOutput->isVerbose()); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function testIsVeryVerbose() |
|
90
|
|
|
{ |
|
91
|
|
|
$this->output->shouldReceive('isVeryVerbose') |
|
92
|
|
|
->with() |
|
93
|
|
|
->andReturn(false); |
|
94
|
|
|
|
|
95
|
|
|
$this->assertEquals(false, $this->diffOutput->isVeryVerbose()); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function testSetVerbosity() |
|
99
|
|
|
{ |
|
100
|
|
|
$this->output->shouldReceive('setVerbosity') |
|
101
|
|
|
->with(OutputInterface::VERBOSITY_NORMAL) |
|
102
|
|
|
->once(); |
|
103
|
|
|
|
|
104
|
|
|
$this->diffOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function testSetDecorated() |
|
108
|
|
|
{ |
|
109
|
|
|
$this->output->shouldReceive('setDecorated') |
|
110
|
|
|
->with(true) |
|
111
|
|
|
->once(); |
|
112
|
|
|
|
|
113
|
|
|
$this->diffOutput->setDecorated(true); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function testSetFormatter() |
|
117
|
|
|
{ |
|
118
|
|
|
$formatter = Mockery::mock(OutputFormatterInterface::class); |
|
119
|
|
|
$this->output->shouldReceive('setFormatter') |
|
120
|
|
|
->with($formatter) |
|
121
|
|
|
->once(); |
|
122
|
|
|
|
|
123
|
|
|
$this->diffOutput->setFormatter($formatter); |
|
|
|
|
|
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|