1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Graze\CiffRenderer\Test; |
4
|
|
|
|
5
|
|
|
use \Mockery as m; |
6
|
|
|
use Graze\CiffRenderer\Field\Parser\FixedTextParser; |
7
|
|
|
use Graze\CiffRenderer\Field\Parser\ParserManager; |
8
|
|
|
|
9
|
|
|
class FixedTextParserTest extends \PHPUnit_Framework_TestCase |
10
|
|
|
{ |
11
|
|
|
protected $parser1; |
12
|
|
|
|
13
|
|
|
protected $parser2; |
14
|
|
|
|
15
|
|
|
protected $parser3; |
16
|
|
|
|
17
|
|
|
public function setUp() |
18
|
|
|
{ |
19
|
|
|
$pwd = dirname(__FILE__); |
20
|
|
|
|
21
|
|
|
$pathToFixture1 = sprintf('%s/Fixture/FixedTextParserFixture1.xml', $pwd); |
22
|
|
|
$pathToFixture2 = sprintf('%s/Fixture/FixedTextParserFixture2.xml', $pwd); |
23
|
|
|
$pathToFixture3 = sprintf('%s/Fixture/FixedTextParserFixture3.xml', $pwd); |
24
|
|
|
|
25
|
|
|
$xml1 = simplexml_load_file($pathToFixture1); |
26
|
|
|
$xml2 = simplexml_load_file($pathToFixture2); |
27
|
|
|
$xml3 = simplexml_load_file($pathToFixture3); |
28
|
|
|
|
29
|
|
|
$this->parser1 = new FixedTextParser(); |
30
|
|
|
$this->parser2 = new FixedTextParser(); |
31
|
|
|
$this->parser3 = new FixedTextParser(); |
32
|
|
|
|
33
|
|
|
// parser 1 and 2 container fixed text, parser 3 contains merge text |
34
|
|
|
$this->parser1->setXmlField($xml1); |
35
|
|
|
$this->parser2->setXmlField($xml2); |
36
|
|
|
$this->parser3->setXmlField($xml3); |
37
|
|
|
|
38
|
|
|
// parser manager required for testing merge text fields |
39
|
|
|
$parserManager = m::mock(ParserManager::class) |
40
|
|
|
->shouldReceive('getParser') |
41
|
|
|
->andReturn($this->parser1, $this->parser2) |
42
|
|
|
->getMock(); |
43
|
|
|
|
44
|
|
|
$this->parser3->setParserManager($parserManager); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testGetFontSize() |
48
|
|
|
{ |
49
|
|
|
$this->assertSame(7.0, $this->parser1->getFontSize()); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testGetFontFace() |
53
|
|
|
{ |
54
|
|
|
$this->assertSame('Arial', $this->parser1->getFontFace()); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testGetOrientation() |
58
|
|
|
{ |
59
|
|
|
$this->assertSame(270, $this->parser1->getOrientation()); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testGetTextFixed() |
63
|
|
|
{ |
64
|
|
|
$this->assertSame('some text', $this->parser1->getText()); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function testGetTextMerged() |
68
|
|
|
{ |
69
|
|
|
$this->assertSame('some text other text', $this->parser3->getText()); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|