Completed
Pull Request — master (#19)
by John
09:10 queued 04:43
created

CiffRendererTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testRenderString() 0 4 1
A getXmlPath() 0 3 1
A testRenderFile() 0 3 1
A setUp() 0 17 1
1
<?php
2
3
namespace Graze\CiffRenderer\Test\Unit;
4
5
use Mockery as m;
6
use Graze\CiffRenderer\Renderer\RendererDocument;
7
use Graze\CiffRenderer\CiffRenderer;
8
9
class CiffRendererTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var CiffRenderer
13
     */
14
    private $ciffRenderer;
15
16
    public function setUp()
17
    {
18
        $xmlExpected = simplexml_load_file($this->getXmlPath());
19
        $fontResolver = function () {}; // @codingStandardsIgnoreLine
20
        $graphicResolver = function () {}; // @codingStandardsIgnoreLine
21
        $argumentValidator = function (\SimpleXMLElement $xmlActual) use ($xmlExpected) {
22
            return (string) $xmlExpected == (string) $xmlActual;
23
        };
24
        $rendererDocument = m::mock(RendererDocument::class)
25
            ->shouldReceive('render')
0 ignored issues
show
Unused Code introduced by
The call to Mockery\MockInterface::shouldReceive() has too many arguments starting with 'render'. ( Ignorable by Annotation )

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

25
            ->/** @scrutinizer ignore-call */ shouldReceive('render')

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...
26
            ->with(m::on($argumentValidator), $fontResolver, $graphicResolver)
27
            ->once()
28
            ->getMock();
29
30
        $this->ciffRenderer = new CiffRenderer($rendererDocument);
0 ignored issues
show
Bug introduced by
$rendererDocument of type Mockery\MockInterface is incompatible with the type Graze\CiffRenderer\Renderer\RendererDocument expected by parameter $rendererDocument of Graze\CiffRenderer\CiffRenderer::__construct(). ( Ignorable by Annotation )

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

30
        $this->ciffRenderer = new CiffRenderer(/** @scrutinizer ignore-type */ $rendererDocument);
Loading history...
31
        $this->ciffRenderer->setFontResolver($fontResolver);
32
        $this->ciffRenderer->setGraphicResolver($graphicResolver);
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    private function getXmlPath()
39
    {
40
        return sprintf('%s/../fixture/document.xml', __DIR__);
41
    }
42
43
    public function testRenderFile()
44
    {
45
        $this->ciffRenderer->renderFile($this->getXmlPath());
46
    }
47
48
    public function testRenderString()
49
    {
50
        $xmlString = file_get_contents($this->getXmlPath());
51
        $this->ciffRenderer->renderString($xmlString);
52
    }
53
}
54