SymfonyConsoleTextFormatterTest::testWrite()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 0
dl 0
loc 16
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\Formatter;
6
7
use PHPUnit\Framework\TestCase;
8
use ReflectionException;
9
use Roave\BackwardCompatibility\Change;
10
use Roave\BackwardCompatibility\Changes;
11
use Roave\BackwardCompatibility\Formatter\SymfonyConsoleTextFormatter;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use function Safe\sprintf;
14
use function uniqid;
15
16
/**
17
 * @covers \Roave\BackwardCompatibility\Formatter\SymfonyConsoleTextFormatter
18
 */
19
final class SymfonyConsoleTextFormatterTest extends TestCase
20
{
21
    /**
22
     * @throws ReflectionException
23
     */
24
    public function testWrite() : void
25
    {
26
        $change1Text = uniqid('change1', true);
27
        $change2Text = uniqid('change2', true);
28
29
        $output = $this->createMock(OutputInterface::class);
30
        $output->expects(self::at(0))
31
            ->method('writeln')
32
            ->with(sprintf('[BC] REMOVED: %s', $change1Text));
33
        $output->expects(self::at(1))
34
            ->method('writeln')
35
            ->with(sprintf('     ADDED: %s', $change2Text));
36
37
        (new SymfonyConsoleTextFormatter($output))->write(Changes::fromList(
38
            Change::removed($change1Text, true),
39
            Change::added($change2Text, false)
40
        ));
41
    }
42
}
43