Completed
Push — master ( fd3130...674c45 )
by John
03:39
created

testGetLineWeight()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Graze\CiffRenderer\Test\Parser\FieldParser;
4
5
use Graze\CiffRenderer\Test\AbstractFieldParserTest;
6
use Graze\CiffRenderer\Parser\FieldParser\FieldParserGraphicPrimitive;
7
use \SimpleXMLElement;
8
9
class FieldParserGraphicPrimitiveTest extends AbstractFieldParserTest
10
{
11
    /**
12
     * @var FieldParserGraphicPrimitive
13
     */
14
    private $parser;
15
16
    /**
17
     * @return SimpleXMLElement
18
     */
19
    protected function getXmlField()
20
    {
21
        return new SimpleXMLElement(
22
            '<Field Name="i am field name">
23
                <FldType>GraphicPrimitive</FldType>
24
                <CLSID>{DC1F7EC4-7698-11D5-8036-005004D10645}</CLSID>
25
                <Displayed>1</Displayed>
26
                <X>4200</X>
27
                <Y>250</Y>
28
                <W>3775</W>
29
                <H>450</H>
30
                <Ln>1</Ln>
31
                <Data>
32
                    <Object>
33
                        <DataType>0</DataType>
34
                    </Object>
35
                </Data>
36
                <Graphic>
37
                    <GfxW>8500</GfxW>
38
                    <GfxH>4700</GfxH>
39
                    <Primitive>
40
                        <Shape>i am shape</Shape>
41
                        <LineW>25</LineW>
42
                    </Primitive>
43
                </Graphic>
44
            </Field>'
45
        );
46
    }
47
48
    /**
49
     * @return FieldParserGraphicPrimitive
50
     */
51
    protected function getParser()
52
    {
53
        if (!$this->parser) {
54
            $this->parser = new FieldParserGraphicPrimitive();
55
        }
56
57
        return $this->parser;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->parser returns the type Graze\CiffRenderer\Parse...dParserGraphicPrimitive which is incompatible with the return type mandated by Graze\CiffRenderer\Test\...ParserTest::getParser() of Graze\CiffRenderer\Test\...er\FieldParserInterface.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
58
    }
59
60
    public function testGetShape()
61
    {
62
        $shape = 'i am shape';
63
        $this->assertEquals($shape, $this->getParser()->getShape());
64
    }
65
66
    public function testGetLineWeight()
67
    {
68
        $lineWeight = 25;
69
        $this->assertEquals($lineWeight, $this->getParser()->getLineWeight());
70
    }
71
}
72