Completed
Pull Request — master (#15)
by John
02:39
created

FixedTextParserTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 63
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
B setUp() 0 29 1
A testGetFontSize() 0 4 1
A testGetFontFace() 0 4 1
A testGetOrientation() 0 4 1
A testGetTextFixed() 0 4 1
A testGetTextMerged() 0 4 1
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;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
12
13
    protected $parser2;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
14
15
    protected $parser3;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
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