-
Notifications
You must be signed in to change notification settings - Fork 259
/
SerializerCompilerPassTest.php
64 lines (49 loc) · 1.82 KB
/
SerializerCompilerPassTest.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace FOS\JsRoutingBundle\Tests\DependencyInjection;
use FOS\JsRoutingBundle\DependencyInjection\FOSJsRoutingExtension;
use FOS\JsRoutingBundle\DependencyInjection\SerializerCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Serializer\Serializer;
/**
* Class SerializerCompilerPassTest
*
* @author Miguel Angel Garzón <magarzon@gmail.com>
*/
class SerializerCompilerPassTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!class_exists('Symfony\Component\DependencyInjection\ContainerBuilder')) {
$this->markTestSkipped('The DependencyInjection component is not available.');
}
}
public function testSerializerInConfig()
{
$container = $this->load([['serializer' => 'test.serializer.service']]);
$compilerPass = new SerializerCompilerPass();
$compilerPass->process($container);
$this->assertTrue($container->hasAlias('fos_js_routing.serializer'));
}
public function testSerializerDefined()
{
$container = $this->load([]);
$container->register('serializer', Serializer::class);
$compilerPass = new SerializerCompilerPass();
$compilerPass->process($container);
$this->assertTrue($container->hasAlias('fos_js_routing.serializer'));
}
public function testSerializerNotDefined()
{
$container = $this->load([]);
$compilerPass = new SerializerCompilerPass();
$compilerPass->process($container);
$this->assertTrue($container->hasDefinition('fos_js_routing.serializer'));
}
private function load(array $configs)
{
$container = new ContainerBuilder();
$extension = new FOSJsRoutingExtension();
$extension->load($configs, $container);
return $container;
}
}