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

FixedTextRendererTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testRender() 0 50 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;
0 ignored issues
show
Bug introduced by
The variable $actualFont does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

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