1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Copyright 2011 Johannes M. Schmitt <[email protected]> |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace JMS\SerializerBundle\Tests\DependencyInjection; |
20
|
|
|
|
21
|
|
|
use JMS\SerializerBundle\JMSSerializerBundle; |
22
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
23
|
|
|
|
24
|
|
|
class ConfigurationTest extends \PHPUnit_Framework_TestCase |
25
|
|
|
{ |
26
|
|
|
private function getContainer(array $configs = array()) |
27
|
|
|
{ |
28
|
|
|
$container = new ContainerBuilder(); |
29
|
|
|
|
30
|
|
|
$container->setParameter('kernel.debug', true); |
31
|
|
|
$container->setParameter('kernel.cache_dir', sys_get_temp_dir() . '/serializer'); |
32
|
|
|
$container->setParameter('kernel.bundles', array('JMSSerializerBundle' => 'JMS\SerializerBundle\JMSSerializerBundle')); |
33
|
|
|
|
34
|
|
|
$bundle = new JMSSerializerBundle(); |
35
|
|
|
|
36
|
|
|
$extension = $bundle->getContainerExtension(); |
37
|
|
|
$extension->load($configs, $container); |
38
|
|
|
|
39
|
|
|
return $container; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testConfig() |
43
|
|
|
{ |
44
|
|
|
$container = $this->getContainer([ |
45
|
|
|
[ |
46
|
|
|
'metadata' => [ |
47
|
|
|
'directories' => [ |
48
|
|
|
[ |
49
|
|
|
'namespace_prefix' => 'JMSSerializerBundleNs1', |
50
|
|
|
'path' => '@JMSSerializerBundle', |
51
|
|
|
], |
52
|
|
|
[ |
53
|
|
|
'namespace_prefix' => 'JMSSerializerBundleNs2', |
54
|
|
|
'path' => '@JMSSerializerBundle/Resources/config', |
55
|
|
|
], |
56
|
|
|
] |
57
|
|
|
] |
58
|
|
|
], |
59
|
|
|
]); |
60
|
|
|
|
61
|
|
|
$directories = $container->getDefinition('jms_serializer.metadata.file_locator')->getArgument(0); |
62
|
|
|
$this->assertEquals('/home/goetas/projects/serializer-bundle', $directories['JMSSerializerBundleNs1']); |
63
|
|
|
$this->assertEquals('/home/goetas/projects/serializer-bundle/Resources/config', $directories['JMSSerializerBundleNs2']); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|