|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Graze\CiffRenderer\Test\Field\Renderer; |
|
4
|
|
|
|
|
5
|
|
|
use \Mockery as m; |
|
6
|
|
|
use Graze\CiffRenderer\Field\Renderer\BarcodeRenderer; |
|
7
|
|
|
use Intervention\Image\ImageManager; |
|
8
|
|
|
use Intervention\Image\Image; |
|
9
|
|
|
|
|
10
|
|
|
class BarcodeRendererTest extends \PHPUnit_Framework_TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
public function testRender() |
|
13
|
|
|
{ |
|
14
|
|
|
$fontResolver = function () { |
|
15
|
|
|
}; |
|
16
|
|
|
$text = 'this is some text'; |
|
17
|
|
|
$width = 104; |
|
18
|
|
|
$height = 102; |
|
19
|
|
|
|
|
20
|
|
|
$canvas = m::mock(Image::class) |
|
|
|
|
|
|
21
|
|
|
->shouldReceive('text') |
|
22
|
|
|
->with($text, 52, $height, m::type('callable')) |
|
23
|
|
|
->shouldReceive('resize') |
|
24
|
|
|
->getMock(); |
|
25
|
|
|
|
|
26
|
|
|
$imageManager = m::mock(ImageManager::class) |
|
27
|
|
|
->shouldReceive('canvas') |
|
28
|
|
|
->with($width, $height, '#000') |
|
29
|
|
|
->andReturn($canvas) |
|
30
|
|
|
->getMock(); |
|
31
|
|
|
|
|
32
|
|
|
$renderer = m::mock(BarcodeRenderer::class) |
|
33
|
|
|
->shouldAllowMockingProtectedMethods() |
|
34
|
|
|
->shouldReceive('getWidth') |
|
35
|
|
|
->andReturn($width) |
|
36
|
|
|
->shouldReceive('getHeight') |
|
37
|
|
|
->andReturn($height) |
|
38
|
|
|
->shouldReceive('getImageManager') |
|
39
|
|
|
->andReturn($imageManager) |
|
40
|
|
|
->shouldReceive('getFontResolver') |
|
41
|
|
|
->andReturn($fontResolver) |
|
42
|
|
|
->shouldReceive('getFontFace') |
|
43
|
|
|
->shouldReceive('getFontSize') |
|
44
|
|
|
->shouldReceive('getText') |
|
45
|
|
|
->andReturn($text) |
|
46
|
|
|
->getMock() |
|
47
|
|
|
->makePartial(); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertSame($canvas, $renderer->render()); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
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.