Completed
Push — master ( a6f474...a67f5b )
by David de
14:12 queued 04:10
created

TableWriterSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_writes_items() 0 20 1
A it_handles_zero_items() 0 6 1
1
<?php
2
3
namespace spec\Port\SymfonyConsole;
4
5
use Symfony\Component\Console\Helper\Table;
6
use PhpSpec\ObjectBehavior;
7
use Prophecy\Argument;
8
9
class TableWriterSpec extends ObjectBehavior
10
{
11
    function let(Table $table)
12
    {
13
        $this->beConstructedWith($table);
14
    }
15
16
    function it_is_initializable()
17
    {
18
        $this->shouldHaveType('Port\SymfonyConsole\TableWriter');
19
    }
20
21
    function it_writes_items(Table $table)
22
    {
23
        $table->addRow(Argument::type('array'))->shouldBeCalledTimes(2);
24
        $table->setHeaders(['first', 'second'])->shouldBeCalled();
25
        $table->render()->shouldBeCalled();
26
27
        $this->prepare();
28
29
        $this->writeItem([
30
            'first'  => 'The first',
31
            'second' => 'Second property',
32
        ]);
33
34
        $this->writeItem([
35
            'first'  => 'Another first',
36
            'second' => 'Last second',
37
        ]);
38
39
        $this->finish();
40
    }
41
42
    function it_handles_zero_items(Table $table)
43
    {
44
        $table->setHeaders([])->shouldBeCalled();
45
        $table->render()->shouldBeCalled();
46
        $this->finish();        
47
    }
48
}
49