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

FieldRendererStaticGraphicTest::testRender()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 24
nc 1
nop 0
dl 0
loc 30
rs 9.536
c 0
b 0
f 0
1
<?php
2
3
namespace Graze\CiffRenderer\Test\Unit\Renderer\FieldRenderer;
4
5
use Mockery as m;
6
use Intervention\Image\Image;
7
use Intervention\Image\ImageManager;
8
use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface;
9
use Graze\CiffRenderer\Renderer\FieldRenderer\FieldRendererStaticGraphic;
10
11
class FieldRendererStaticGraphicTest extends \PHPUnit_Framework_TestCase
12
{
13
    public function testRender()
14
    {
15
        $imageRaw = 'fake image';
16
        $imageExptected = m::mock(Image::class);
17
        $imageManager = m::mock(ImageManager::class)
18
            ->shouldReceive('make')
0 ignored issues
show
Unused Code introduced by
The call to Mockery\MockInterface::shouldReceive() has too many arguments starting with 'make'. ( Ignorable by Annotation )

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

18
            ->/** @scrutinizer ignore-call */ shouldReceive('make')

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...
19
            ->with($imageRaw)
20
            ->andReturn($imageExptected)
21
            ->once()
22
            ->getMock();
23
        $pathExpected = '/path/to/graphic';
24
        $parser = m::mock(FieldParserInterface::class)
25
            ->shouldReceive('getGraphic')
26
            ->andReturn($pathExpected)
27
            ->once()
28
            ->getMock();
29
        $graphicResolver = function ($path) use ($pathExpected, $imageRaw) {
30
            $this->assertEquals($pathExpected, $path);
31
            return $imageRaw;
32
        };
33
34
        $renderer = new FieldRendererStaticGraphic();
35
        $image = $renderer->render(
36
            $imageManager,
0 ignored issues
show
Bug introduced by
$imageManager of type Mockery\MockInterface is incompatible with the type Intervention\Image\ImageManager expected by parameter $imageManager of Graze\CiffRenderer\Rende...StaticGraphic::render(). ( Ignorable by Annotation )

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

36
            /** @scrutinizer ignore-type */ $imageManager,
Loading history...
37
            $parser,
0 ignored issues
show
Bug introduced by
$parser of type Mockery\MockInterface is incompatible with the type Graze\CiffRenderer\Parse...er\FieldParserInterface expected by parameter $parser of Graze\CiffRenderer\Rende...StaticGraphic::render(). ( Ignorable by Annotation )

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

37
            /** @scrutinizer ignore-type */ $parser,
Loading history...
38
            null,
39
            $graphicResolver
40
        );
41
42
        $this->assertEquals($imageExptected, $image);
43
    }
44
}
45