Completed
Pull Request — master (#15)
by John
02:41
created

FixedTextRendererTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 6
Bugs 1 Features 0
Metric Value
wmc 2
c 6
b 1
f 0
lcom 0
cbo 6
dl 0
loc 52
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testRender() 0 49 2
1
<?php
2
3
namespace Graze\CiffRenderer\Test\Field\Renderer;
4
5
use \Mockery as m;
6
use Graze\CiffRenderer\Field\Renderer\FixedTextRenderer;
7
use Intervention\Image\ImageManager;
8
use Intervention\Image\Image;
9
10
class FixedTextRendererTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testRender()
13
    {
14
        $fontResolver = function () {
15
        };
16
        $text = 'this is some text';
17
        $fontSize = 42;
18
        $orientation = 90;
19
        $tracerColour = '#ccc';
20
21
        $textExpectation = function ($actualClosure) use ($text, $fontSize) {
22
            $actualFont = null;
23
            $actualClosure($actualFont);
24
            return $actualFont->getText() == $text && $actualFont->getSize() == $fontSize;
0 ignored issues
show
Bug introduced by
The method getText cannot be called on $actualFont (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
Bug introduced by
The method getSize cannot be called on $actualFont (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
25
        };
26
27
        $canvas = m::mock(Image::class)
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

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...
28
            ->shouldReceive('text')
29
            ->with('', null, null, m::on($textExpectation))
30
            ->shouldReceive('resize')
31
            ->shouldReceive('rotate')
32
            ->with(360 - $orientation)
33
            ->getMock();
34
35
        $imageManager = m::mock(ImageManager::class)
36
            ->shouldReceive('canvas')
37
            ->with(m::type('int'), m::type('int'), $tracerColour)
38
            ->andReturn($canvas)
39
            ->getMock();
40
41
        $renderer = m::mock(FixedTextRenderer::class)
42
            ->shouldAllowMockingProtectedMethods()
43
            ->shouldReceive('getImageManager')
44
            ->andReturn($imageManager)
45
            ->shouldReceive('getFontResolver')
46
            ->andReturn($fontResolver)
47
            ->shouldReceive('getFontFace')
48
            ->shouldReceive('getFontSize')
49
            ->andReturn($fontSize)
50
            ->shouldReceive('getText')
51
            ->andReturn($text)
52
            ->shouldReceive('getOrientation')
53
            ->andReturn($orientation)
54
            ->shouldReceive('getTracerColour')
55
            ->andReturn($tracerColour)
56
            ->getMock()
57
            ->makePartial();
58
59
        $this->assertSame($canvas, $renderer->render());
60
    }
61
}
62