|
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); |
|
|
|
|
|
|
27
|
|
|
$node->getChild('closing')->willReturn($closing); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
44
|
|
|
$node->getChild('closing')->willReturn($closing); |
|
|
|
|
|
|
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
|
|
|
|
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.