|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Graze\CiffRenderer\Test; |
|
4
|
|
|
|
|
5
|
|
|
use Mockery as m; |
|
6
|
|
|
use \SimpleXMLElement; |
|
7
|
|
|
use Graze\CiffRenderer\Parser\FieldParserRegistry; |
|
8
|
|
|
use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface; |
|
9
|
|
|
|
|
10
|
|
|
abstract class AbstractFieldParserTest extends \PHPUnit_Framework_TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var FieldParserRegistry |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $fieldParserRegistry; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var SimpleXMLElement |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $xmlHeader; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var float |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $scale; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var FieldParserInterface |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $parser; |
|
31
|
|
|
|
|
32
|
|
|
public function setUp() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->fieldParserRegistry = m::mock(FieldParserRegistry::class); |
|
35
|
|
|
$this->xmlHeader = new SimpleXMLElement('<root/>'); |
|
36
|
|
|
$this->scale = 1.5; |
|
37
|
|
|
|
|
38
|
|
|
$this->parser = $this->getParser(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Returns the Parser we are testing. |
|
43
|
|
|
* |
|
44
|
|
|
* @return FieldParserInterface |
|
45
|
|
|
*/ |
|
46
|
|
|
abstract protected function getParser(); |
|
47
|
|
|
|
|
48
|
|
|
public function testGetFieldName() |
|
49
|
|
|
{ |
|
50
|
|
|
$fieldName = 'i am field name'; |
|
51
|
|
|
$this->assertEquals($fieldName, $this->parser->getFieldName()); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function testGetPositionX() |
|
55
|
|
|
{ |
|
56
|
|
|
$expected = 6300; |
|
57
|
|
|
$this->assertEquals($expected, $this->parser->getPositionX()); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testGetPositionY() |
|
61
|
|
|
{ |
|
62
|
|
|
$expected = 375; |
|
63
|
|
|
$this->assertEquals($expected, $this->parser->getPositionY()); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function testGetWidth() |
|
67
|
|
|
{ |
|
68
|
|
|
$expected = 5662; |
|
69
|
|
|
$this->assertEquals($expected, $this->parser->getWidth()); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function testGetHeight() |
|
73
|
|
|
{ |
|
74
|
|
|
$expected = 675; |
|
75
|
|
|
$this->assertEquals($expected, $this->parser->getHeight()); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function testisDisplayed() |
|
79
|
|
|
{ |
|
80
|
|
|
$this->assertSame(true, $this->parser->isDisplayed()); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|