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

AbstractFieldParserTest::testGetPositionY()   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;
4
5
use Mockery as m;
6
use \SimpleXMLElement;
7
use Graze\CiffRenderer\Parser\FieldParserRegistry;
8
9
abstract class AbstractFieldParserTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var FieldParserRegistry
13
     */
14
    protected $fieldParserRegistry;
15
16
    public function setUp()
17
    {
18
        $parser = $this->getParser();
19
20
        $this->fieldParserRegistry = m::mock(FieldParserRegistry::class)
0 ignored issues
show
Documentation Bug introduced by
It seems like Mockery::mock(Graze\Ciff...ser)->once()->getMock() of type Mockery\MockInterface is incompatible with the declared type Graze\CiffRenderer\Parser\FieldParserRegistry of property $fieldParserRegistry.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
21
            ->shouldReceive('addParser')
0 ignored issues
show
Unused Code introduced by
The call to Mockery\MockInterface::shouldReceive() has too many arguments starting with 'addParser'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
            ->/** @scrutinizer ignore-call */ shouldReceive('addParser')

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
22
            ->with($parser)
23
            ->once()
24
            ->getMock();
25
26
        $xmlField = $this->getXmlField();
27
28
        $xmlHeader = new SimpleXMLElement(
29
            '<Header>
30
                <DateOffset Name="lifetime">
31
                    <DefaultOffset>
32
                        <Day>130</Day>
33
                    </DefaultOffset>
34
                </DateOffset>
35
            </Header>'
36
        );
37
38
        $scale = 1.5;
39
40
        $parser->parse(
41
            $this->fieldParserRegistry,
42
            $xmlField,
43
            $xmlHeader,
44
            $scale
45
        );
46
    }
47
48
    /**
49
     * Returns the XML we are attempting to parse.
50
     *
51
     * @var SimpleXMLElement
52
     */
53
    abstract protected function getXmlField();
54
55
    /**
56
     * Returns the Parser we are testing.
57
     *
58
     * @return Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface
0 ignored issues
show
Bug introduced by
The type Graze\CiffRenderer\Test\...er\FieldParserInterface was not found. Did you mean Graze\CiffRenderer\Parse...er\FieldParserInterface? If so, make sure to prefix the type with \.
Loading history...
59
     */
60
    abstract protected function getParser();
61
62
    public function testGetFieldName()
63
    {
64
        $fieldName = 'i am field name';
65
        $this->assertEquals($fieldName, $this->getParser()->getFieldName());
66
    }
67
68
    public function testGetPositionX()
69
    {
70
        $expected = 6300;
71
        $this->assertEquals($expected, $this->getParser()->getPositionX());
72
    }
73
74
    public function testGetPositionY()
75
    {
76
        $expected = 375;
77
        $this->assertEquals($expected, $this->getParser()->getPositionY());
78
    }
79
80
    public function testGetWidth()
81
    {
82
        $expected = 5662;
83
        $this->assertEquals($expected, $this->getParser()->getWidth());
84
    }
85
86
    public function testGetHeight()
87
    {
88
        $expected = 675;
89
        $this->assertEquals($expected, $this->getParser()->getHeight());
90
    }
91
92
    public function testisDisplayed()
93
    {
94
        $this->assertSame(true, $this->getParser()->isDisplayed());
95
    }
96
}
97