Completed
Pull Request — master (#15)
by James
02:25
created

SymfonyConsoleTextFormatterTest::testWrite()   A

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.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace RoaveTest\ApiCompare\Formatter;
5
6
use Roave\ApiCompare\Change;
7
use Roave\ApiCompare\Changes;
8
use Roave\ApiCompare\Formatter\SymfonyConsoleTextFormatter;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
/**
13
 * @covers \Roave\ApiCompare\Formatter\SymfonyConsoleTextFormatter
14
 */
15
final class SymfonyConsoleTextFormatterTest extends TestCase
16
{
17
    /**
18
     * @throws \ReflectionException
19
     */
20
    public function testWrite() : void
21
    {
22
        $change1Text = uniqid('change1', true);
23
        $change2Text = uniqid('change2', true);
24
25
        $output = $this->createMock(OutputInterface::class);
26
        $output->expects(self::at(0))
27
            ->method('writeln')
28
            ->with(sprintf('[BC] REMOVED: %s', $change1Text));
0 ignored issues
show
Bug introduced by
sprintf('[BC] REMOVED: %s', $change1Text) of type string is incompatible with the type array expected by parameter $arguments of PHPUnit\Framework\MockOb...nvocationMocker::with(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

28
            ->with(/** @scrutinizer ignore-type */ sprintf('[BC] REMOVED: %s', $change1Text));
Loading history...
29
        $output->expects(self::at(1))
30
            ->method('writeln')
31
            ->with(sprintf('     ADDED: %s', $change2Text));
32
33
        (new SymfonyConsoleTextFormatter($output))->write(Changes::fromArray([
34
            Change::removed($change1Text, true),
35
            Change::added($change2Text, false),
36
        ]));
37
    }
38
}
39