Completed
Push — refactor-04-parser-tests ( dc4950...bd4663 )
by John
06:06
created

FieldParserBarcodeTest::testGetText()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 35

Duplication

Lines 42
Ratio 100 %

Importance

Changes 0
Metric Value
dl 42
loc 42
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 35
nc 1
nop 0
1
<?php
2
3
namespace Graze\CiffRenderer\Test\Parser\FieldParser;
4
5
use Mockery as m;
6
use Graze\CiffRenderer\Test\AbstractFieldParserTest;
7
use Graze\CiffRenderer\Parser\FieldParser\FieldParserBarcode;
8
use Graze\CiffRenderer\Test\SimpleXmlElementChainMocker;
9
10
class FieldParserBarcodeTest extends AbstractFieldParserTest
11
{
12
    /**
13
     * @var FieldParserBarcode
14
     */
15
    private $parser;
16
17
    /**
18
     * @return FieldParserBarcode
19
     */
20
    protected function getParser()
21
    {
22
        if (!$this->parser) {
23
            $this->parser = new FieldParserBarcode();
24
        }
25
26
        return $this->parser;
27
    }
28
29
    public function testGetFontSize()
30
    {
31
        $size = 3.4;
32
        SimpleXmlElementChainMocker::addChain(['xmlField', 'Barcode', 'HR', 'HRFont', 'Pitch'], $size);
33
34
        $this->assertEquals($size, $this->getParser()->getFontSize());
35
    }
36
37 View Code Duplication
    public function testGetFontFace()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $face = 'i am face';
40
        SimpleXmlElementChainMocker::addChain(['xmlField', 'Text', 'Font', 'Face'], $face);
41
42
        $this->assertEquals($face, $this->getParser()->getFontFace());
43
    }
44
45 View Code Duplication
    public function testGetOrientation()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
    {
47
        $orientation = 90;
48
        SimpleXmlElementChainMocker::addChain(['xmlField', 'Orientation'], $orientation);
49
50
        $this->assertEquals($orientation, $this->getParser()->getOrientation());
51
    }
52
53 View Code Duplication
    public function testGetText()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55
        $srcFieldName = 'i am source field';
56
        $fieldMerge = SimpleXmlElementChainMocker::mock(['fieldMerge']);
57
        $fieldMerge
58
            ->shouldReceive('__get')
59
            ->with('SrcField')
60
            ->andReturn($fieldMerge)
61
            ->twice()
62
            ->shouldReceive('attributes')
63
            ->andReturn($fieldMerge)
64
            ->once()
65
            ->shouldReceive('__get')
66
            ->with('SrcFieldName')
67
            ->andReturn($srcFieldName)
68
            ->once()
69
            ->getMock();
70
71
        $fieldMergeText = 'i am merge text';
72
        $fieldMergeSource = m::mock(FieldParserFixedText::class)
73
            ->shouldReceive('getText')
74
            ->andReturn($fieldMergeText)
75
            ->once()
76
            ->getMock();
77
78
        $this->fieldParserRegistry
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Graze\CiffRendere...er\FieldParserRegistry>.

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.

Loading history...
79
            ->shouldReceive('getParser')
80
            ->with($srcFieldName)
81
            ->andReturn($fieldMergeSource)
82
            ->once()
83
            ->getMock();
84
85
        $fieldStandardText = 'i am standard text';
86
        $fieldStandard = SimpleXmlElementChainMocker::mock(['fieldStandard']);
87
        SimpleXmlElementChainMocker::addChain(['fieldStandard', 'SrcField'], false);
88
        SimpleXmlElementChainMocker::addChain(['fieldStandard', 'Default'], $fieldStandardText);
89
90
        $objects = [$fieldMerge, $fieldStandard];
91
        SimpleXmlElementChainMocker::addChain(['xmlField', 'Data', 'Object'], $objects);
92
93
        $this->assertEquals($fieldMergeText . $fieldStandardText, $this->getParser()->getText());
94
    }
95
96 View Code Duplication
    public function testGetIsInverse()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
97
    {
98
        $isInverse = 1;
99
        SimpleXmlElementChainMocker::addChain(['xmlField', 'Inverse'], $isInverse);
100
101
        $this->assertEquals(true, $this->getParser()->getOrientation());
102
    }
103
}
104