Passed
Push — refactor-03-simple-xml-replace ( b520e3...e5037f )
by John
07:31
created

CiffRendererTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 0
dl 0
loc 17
rs 9.8333
c 0
b 0
f 0
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
use Illuminate\Filesystem\Filesystem;
9
use Graze\CiffRenderer\Parser\SimpleXmlElementInterface;
10
use Intervention\Image\Image;
11
12
class CiffRendererTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var string
16
     */
17
    private $xmlString = '<xml/>';
18
19
    /**
20
     * @var Image
21
     */
22
    private $imageExpected;
23
24
    /**
25
     * @var Filesystem
26
     */
27
    private $filesystem;
28
29
    /**
30
     * @var CiffRenderer
31
     */
32
    private $ciffRenderer;
33
34
    public function setUp()
35
    {
36
        $this->imageExpected = m::mock(Image::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like Mockery::mock(Intervention\Image\Image::class) of type Mockery\MockInterface is incompatible with the declared type Intervention\Image\Image of property $imageExpected.

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...
37
        $this->filesystem = m::mock(Filesystem::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like Mockery::mock(Illuminate...stem\Filesystem::class) of type Mockery\MockInterface is incompatible with the declared type Illuminate\Filesystem\Filesystem of property $filesystem.

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...
38
39
        $fontResolver = function () {}; // @codingStandardsIgnoreLine
40
        $graphicResolver = function () {}; // @codingStandardsIgnoreLine
41
        $rendererDocument = m::mock(RendererDocument::class)
42
            ->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

42
            ->/** @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...
43
            ->with(m::type(SimpleXmlElementInterface::class), $fontResolver, $graphicResolver)
44
            ->andReturn($this->imageExpected)
45
            ->once()
46
            ->getMock();
47
48
        $this->ciffRenderer = new CiffRenderer($this->filesystem, $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

48
        $this->ciffRenderer = new CiffRenderer($this->filesystem, /** @scrutinizer ignore-type */ $rendererDocument);
Loading history...
Bug introduced by
$this->filesystem of type Mockery\MockInterface is incompatible with the type Illuminate\Filesystem\Filesystem expected by parameter $filesystem 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

48
        $this->ciffRenderer = new CiffRenderer(/** @scrutinizer ignore-type */ $this->filesystem, $rendererDocument);
Loading history...
49
        $this->ciffRenderer->setFontResolver($fontResolver);
50
        $this->ciffRenderer->setGraphicResolver($graphicResolver);
51
    }
52
53
    public function testRenderFile()
54
    {
55
        $path = '/path/to/file';
56
        $this->filesystem
57
            ->shouldReceive('get')
58
            ->with($path)
59
            ->andReturn($this->xmlString)
60
            ->once()
61
            ->getMock();
62
63
        $imageActual = $this->ciffRenderer->renderFile($path);
64
        $this->assertSame($this->imageExpected, $imageActual);
65
    }
66
67
    public function testRenderString()
68
    {
69
        $imageActual = $this->ciffRenderer->renderString($this->xmlString);
70
        $this->assertSame($this->imageExpected, $imageActual);
71
    }
72
}
73