Completed
Push — master ( e6fe6f...a29d2d )
by Hannes
09:33
created

LayoutProcessorSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_fails_on_missmatching_dates() 0 15 1
A it_fails_on_wrong_record_count() 0 16 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace spec\byrokrat\autogiro\Processor;
6
7
use byrokrat\autogiro\Processor\LayoutProcessor;
8
use byrokrat\autogiro\Tree\LayoutNode;
9
use byrokrat\autogiro\Tree\OpeningNode;
10
use byrokrat\autogiro\Tree\ClosingNode;
11
use PhpSpec\ObjectBehavior;
12
13
class LayoutProcessorSpec extends ObjectBehavior
14
{
15
    function it_is_initializable()
16
    {
17
        $this->shouldHaveType(LayoutProcessor::CLASS);
18
    }
19
20
    function it_fails_on_missmatching_dates(LayoutNode $node, OpeningNode $opening, ClosingNode $closing)
21
    {
22
        $opening->getAttribute('date')->willReturn(new \DateTime('2010'));
23
        $closing->getAttribute('date')->willReturn(new \DateTime('2011'));
24
        $closing->getAttribute('nr_of_posts')->willReturn(0);
25
        $closing->getLineNr()->willReturn(1);
26
        $node->getChild('opening')->willReturn($opening);
0 ignored issues
show
Bug introduced by
The method willReturn() does not seem to exist on object<byrokrat\autogiro\Tree\Node>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        $node->getChild('closing')->willReturn($closing);
0 ignored issues
show
Bug introduced by
The method willReturn() does not seem to exist on object<byrokrat\autogiro\Tree\Node>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
        $node->getChildren()->willReturn([$opening, $closing]);
29
30
        $this->visitLayoutNode($node);
31
32
        $this->hasErrors()->shouldEqual(true);
33
        $this->getErrors()->shouldHaveCount(1);
34
    }
35
36
    function it_fails_on_wrong_record_count(LayoutNode $node, OpeningNode $opening, ClosingNode $closing)
37
    {
38
        $date = new \DateTime;
39
        $opening->getAttribute('date')->willReturn($date);
40
        $closing->getAttribute('date')->willReturn($date);
41
        $closing->getAttribute('nr_of_posts')->willReturn(1);
42
        $closing->getLineNr()->willReturn(1);
43
        $node->getChild('opening')->willReturn($opening);
0 ignored issues
show
Bug introduced by
The method willReturn() does not seem to exist on object<byrokrat\autogiro\Tree\Node>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
        $node->getChild('closing')->willReturn($closing);
0 ignored issues
show
Bug introduced by
The method willReturn() does not seem to exist on object<byrokrat\autogiro\Tree\Node>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
        $node->getChildren()->willReturn([$opening, $closing]);
46
47
        $this->visitLayoutNode($node);
48
49
        $this->hasErrors()->shouldEqual(true);
50
        $this->getErrors()->shouldHaveCount(1);
51
    }
52
}
53