1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Graze\CiffRenderer\Test; |
4
|
|
|
|
5
|
|
|
use Mockery as m; |
6
|
|
|
use \SimpleXMLElement; |
7
|
|
|
use Graze\CiffRenderer\Parser\FieldParserRegistry; |
8
|
|
|
|
9
|
|
|
abstract class AbstractFieldParserTest extends \PHPUnit_Framework_TestCase |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var FieldParserRegistry |
13
|
|
|
*/ |
14
|
|
|
protected $fieldParserRegistry; |
15
|
|
|
|
16
|
|
|
public function setUp() |
17
|
|
|
{ |
18
|
|
|
$parser = $this->getParser(); |
19
|
|
|
|
20
|
|
|
$this->fieldParserRegistry = m::mock(FieldParserRegistry::class) |
|
|
|
|
21
|
|
|
->shouldReceive('addParser') |
|
|
|
|
22
|
|
|
->with($parser) |
23
|
|
|
->once() |
24
|
|
|
->getMock(); |
25
|
|
|
|
26
|
|
|
$xmlField = $this->getXmlField(); |
27
|
|
|
|
28
|
|
|
$xmlHeader = new SimpleXMLElement( |
29
|
|
|
'<Header> |
30
|
|
|
<DateOffset Name="lifetime"> |
31
|
|
|
<DefaultOffset> |
32
|
|
|
<Day>130</Day> |
33
|
|
|
</DefaultOffset> |
34
|
|
|
</DateOffset> |
35
|
|
|
</Header>' |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
$scale = 1.5; |
39
|
|
|
|
40
|
|
|
$parser->parse( |
41
|
|
|
$this->fieldParserRegistry, |
42
|
|
|
$xmlField, |
43
|
|
|
$xmlHeader, |
44
|
|
|
$scale |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Returns the XML we are attempting to parse. |
50
|
|
|
* |
51
|
|
|
* @var SimpleXMLElement |
52
|
|
|
*/ |
53
|
|
|
abstract protected function getXmlField(); |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Returns the Parser we are testing. |
57
|
|
|
* |
58
|
|
|
* @return Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface |
|
|
|
|
59
|
|
|
*/ |
60
|
|
|
abstract protected function getParser(); |
61
|
|
|
|
62
|
|
|
public function testGetFieldName() |
63
|
|
|
{ |
64
|
|
|
$fieldName = 'i am field name'; |
65
|
|
|
$this->assertEquals($fieldName, $this->getParser()->getFieldName()); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function testGetPositionX() |
69
|
|
|
{ |
70
|
|
|
$expected = 6300; |
71
|
|
|
$this->assertEquals($expected, $this->getParser()->getPositionX()); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function testGetPositionY() |
75
|
|
|
{ |
76
|
|
|
$expected = 375; |
77
|
|
|
$this->assertEquals($expected, $this->getParser()->getPositionY()); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function testGetWidth() |
81
|
|
|
{ |
82
|
|
|
$expected = 5662; |
83
|
|
|
$this->assertEquals($expected, $this->getParser()->getWidth()); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function testGetHeight() |
87
|
|
|
{ |
88
|
|
|
$expected = 675; |
89
|
|
|
$this->assertEquals($expected, $this->getParser()->getHeight()); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function testisDisplayed() |
93
|
|
|
{ |
94
|
|
|
$this->assertSame(true, $this->getParser()->isDisplayed()); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..