Completed
Branch master (4d68bf)
by John
01:46
created

FieldRendererFilledBoxTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 40
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testRender() 0 48 1
1
<?php
2
3
namespace Graze\CiffRenderer\Test\Unit\Renderer\FieldRenderer\GraphicPrimitive;
4
5
use Mockery as m;
6
use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface;
7
use Intervention\Image\Image;
8
use Intervention\Image\ImageManager;
9
use Graze\CiffRenderer\Renderer\FieldRenderer\GraphicPrimitive\FieldRendererFilledBox;
10
11
class FieldRendererFilledBoxTest extends \PHPUnit_Framework_TestCase
12
{
13
    public function testRender()
14
    {
15
        $width = 2;
16
        $height = 4;
17
        $lineWeight = 1;
18
        $parser = m::mock(FieldParserInterface::class)
19
            ->shouldReceive('getWidth')
0 ignored issues
show
Unused Code introduced by
The call to Mockery\MockInterface::shouldReceive() has too many arguments starting with 'getWidth'. ( Ignorable by Annotation )

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

19
            ->/** @scrutinizer ignore-call */ shouldReceive('getWidth')

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...
20
            ->andReturn($width)
21
            ->twice()
22
            ->shouldReceive('getHeight')
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not exist on Mockery\Expectation. ( Ignorable by Annotation )

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

22
            ->/** @scrutinizer ignore-call */ shouldReceive('getHeight')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
            ->andReturn($height)
24
            ->twice()
25
            ->shouldReceive('getLineWeight')
26
            ->andReturn($lineWeight)
27
            ->times(3)
28
            ->getMock();
29
30
        $rectangle = m::mock('rectangle')
31
            ->shouldReceive('border')
32
            ->with($lineWeight, '#000')
33
            ->once()
34
            ->shouldReceive('background')
35
            ->with('#000')
36
            ->getMock();
37
38
        $closureExpection = function ($closureActual) use ($rectangle) {
39
            $closureActual($rectangle);
40
            return true;
41
        };
42
        $image = m::mock(Image::class)
43
            ->shouldReceive('rectangle')
44
            ->with(0, 0, $width - $lineWeight, $height - $lineWeight, m::on($closureExpection))
45
            ->once()
46
            ->getMock();
47
48
        $imageManager = m::mock(ImageManager::class)
49
            ->shouldReceive('canvas')
50
            ->with($width, $height)
51
            ->andReturn($image)
52
            ->getMock();
53
54
        $renderer = new FieldRendererFilledBox();
55
        $imageActual = $renderer->render(
56
            $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...ctBoxRenderer::render(). ( Ignorable by Annotation )

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

56
            /** @scrutinizer ignore-type */ $imageManager,
Loading history...
57
            $parser
58
        );
59
60
        $this->assertSame($image, $imageActual);
61
    }
62
}
63