/
CacheResolvedTest.php
41 lines (34 loc) · 1.47 KB
/
CacheResolvedTest.php
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
<?php
namespace Liip\ImagineBundle\Tests\Async;
use Enqueue\Bundle\EnqueueBundle;
use Liip\ImagineBundle\Async\CacheResolved;
class CacheResolvedTest extends \PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass()
{
if (!class_exists(EnqueueBundle::class)) {
self::markTestSkipped('The tests are run without enqueue integration. Skip them');
}
}
public function testCouldBeJsonSerialized()
{
$message = new CacheResolved('thePath', array(
'fooFilter' => 'http://example.com/fooFilter/thePath',
'barFilter' => 'http://example.com/barFilter/thePath',
));
$this->assertEquals(
'{"path":"thePath","uris":{"fooFilter":"http:\/\/example.com\/fooFilter\/thePath","barFilter":"http:\/\/example.com\/barFilter\/thePath"}}',
json_encode($message)
);
}
public function testCouldBeJsonDeSerialized()
{
$message = CacheResolved::jsonDeserialize('{"path":"thePath","uris":{"fooFilter":"http:\/\/example.com\/fooFilter\/thePath","barFilter":"http:\/\/example.com\/barFilter\/thePath"}}');
$this->assertInstanceOf('Liip\ImagineBundle\Async\CacheResolved', $message);
$this->assertEquals('thePath', $message->getPath());
$this->assertEquals(array(
'fooFilter' => 'http://example.com/fooFilter/thePath',
'barFilter' => 'http://example.com/barFilter/thePath',
), $message->getUris());
}
}