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

FieldRendererOutlineBoxTest::testRender()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 46
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 37
nc 1
nop 0
dl 0
loc 46
rs 9.328
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\Gd\Font;
7
use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface;
8
use Intervention\Image\Image;
9
use Intervention\Image\ImageManager;
10
use Graze\CiffRenderer\Renderer\FieldRenderer\FieldRendererOutlineBox;
0 ignored issues
show
Bug introduced by
The type Graze\CiffRenderer\Rende...FieldRendererOutlineBox was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
class FieldRendererOutlineBoxTest extends \PHPUnit_Framework_TestCase
13
{
14
    public function testRender()
15
    {
16
        $width = 2;
17
        $height = 4;
18
        $lineWeight = 1;
19
        $parser = m::mock(FieldParserInterface::class)
20
            ->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

20
            ->/** @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...
21
            ->andReturn($width)
22
            ->twice()
23
            ->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

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