Completed
Push — master ( 3feeea...9fb957 )
by David de
04:08
created

ConsoleProgressWriterTest::testWrite()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 35
rs 8.8571
cc 1
eloc 25
nc 1
nop 0
1
<?php
2
3
namespace Ddeboer\DataImport\Tests\Writer;
4
5
use Ddeboer\DataImport\Writer\ConsoleProgressWriter;
6
use Ddeboer\DataImport\Workflow\StepAggregator;
7
use Ddeboer\DataImport\Reader\ArrayReader;
8
use Symfony\Component\Console\Output\NullOutput;
9
10
class ConsoleProgressWriterTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testWrite()
13
    {
14
        $data = array(
15
            array(
16
                'first'  => 'The first',
17
                'second' => 'Second property'
18
            ), array(
19
                'first'  => 'Another first',
20
                'second' => 'Last second'
21
            )
22
        );
23
        $reader = new ArrayReader($data);
24
25
        $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')
26
            ->getMock();
27
28
        $outputFormatter = $this->getMock('Symfony\Component\Console\Formatter\OutputFormatterInterface');
29
        $output->expects($this->once())
30
            ->method('isDecorated')
31
            ->will($this->returnValue(true));
32
33
        $output->expects($this->atLeastOnce())
34
            ->method('getFormatter')
35
            ->will($this->returnValue($outputFormatter));
36
37
        $output->expects($this->atLeastOnce())
38
            ->method('write');
39
        $writer = new ConsoleProgressWriter($output, $reader);
40
41
        $workflow = new StepAggregator($reader);
42
        $workflow->addWriter($writer)
43
            ->process();
44
45
        $this->assertEquals('debug', $writer->getVerbosity());
46
    }
47
}
48