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

ConsoleProgressWriterTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 1
c 3
b 0
f 1
lcom 0
cbo 3
dl 0
loc 38
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testWrite() 0 35 1
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