Completed
Pull Request — master (#35)
by James
02:21
created

testWrite()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 26
nc 1
nop 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\MarkdownPipedToSymfonyConsoleFormatter;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
/**
13
 * @covers \Roave\ApiCompare\Formatter\MarkdownPipedToSymfonyConsoleFormatter
14
 */
15
final class MarkdownPipedToSymfonyConsoleFormatterTest extends TestCase
16
{
17
    public function testWrite() : void
18
    {
19
        $output = $this->createMock(OutputInterface::class);
20
21
        $changeToExpect = <<<EOF
22
# Added
23
 - [BC] Something added
24
 - Something added
25
26
# Changed
27
 - [BC] Something changed
28
 - Something changed
29
30
# Removed
31
 - [BC] Something removed
32
 - Something removed
33
34
EOF;
35
36
        $output->expects(self::any())
37
            ->method('writeln')
38
            ->willReturnCallback(function (string $output) use ($changeToExpect) {
39
                self::assertContains($changeToExpect, $output);
40
            });
41
42
        (new MarkdownPipedToSymfonyConsoleFormatter($output))->write(Changes::fromArray([
43
            Change::added('Something added', true),
44
            Change::added('Something added', false),
45
            Change::changed('Something changed', true),
46
            Change::changed('Something changed', false),
47
            Change::removed('Something removed', true),
48
            Change::removed('Something removed', false),
49
        ]));
50
    }
51
}
52