forked from liip/LiipImagineBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWarmupCacheHandlerTest.php
More file actions
89 lines (73 loc) · 2.52 KB
/
WarmupCacheHandlerTest.php
File metadata and controls
89 lines (73 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
declare(strict_types=1);
/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Liip\ImagineBundle\Tests\Message\Handler;
use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException;
use Liip\ImagineBundle\Imagine\Filter\FilterManager;
use Liip\ImagineBundle\Message\Handler\WarmupCacheHandler;
use Liip\ImagineBundle\Message\WarmupCache;
use Liip\ImagineBundle\Service\FilterService;
use Liip\ImagineBundle\Tests\Functional\AbstractWebTestCase;
use ReflectionClass;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
use Symfony\Component\Messenger\MessageBusInterface;
/**
* @requires PHP 7.1
*
* @covers \Liip\ImagineBundle\Message\Handler\WarmupCacheHandler
*/
class WarmupCacheHandlerTest extends AbstractWebTestCase
{
protected function setUp(): void
{
if (!interface_exists(MessageBusInterface::class)) {
$this->markTestSkipped('Requires the symfony/messenger package.');
}
}
public function testShouldImplementMessageHandlerInterface(): void
{
$rc = new ReflectionClass(WarmupCacheHandler::class);
$this->assertTrue($rc->implementsInterface(MessageHandlerInterface::class));
}
public function testCouldBeConstructedWithExpectedArguments(): void
{
static::createClient();
$handler = new WarmupCacheHandler(
$this->createFilterManagerMock(),
$this->createFilterServiceMock()
);
$this->assertInstanceOf(WarmupCacheHandler::class, $handler);
}
public function testThrowIfMessageMissingPath(): void
{
static::createClient();
$handler = new WarmupCacheHandler(
$this->createFilterManagerMock(),
$this->createFilterServiceMock()
);
$this->expectException(NotLoadableException::class);
$this->expectExceptionMessage('Source image not resolvable "thePath"');
$handler->__invoke(new WarmupCache('thePath', null, true));
}
/**
* @return object|FilterManager
*/
private function createFilterManagerMock()
{
return $this->getService('test.liip_imagine.filter.manager');
}
/**
* @return object|FilterService
*/
private function createFilterServiceMock()
{
return $this->getService('test.liip_imagine.service.filter');
}
}