|
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
|
|
|
$ref = new JMSSerializerBundle(); |
|
45
|
|
|
$container = $this->getContainer([ |
|
46
|
|
|
[ |
|
47
|
|
|
'metadata' => [ |
|
48
|
|
|
'directories' => [ |
|
49
|
|
|
[ |
|
50
|
|
|
'namespace_prefix' => 'JMSSerializerBundleNs1', |
|
51
|
|
|
'path' => '@JMSSerializerBundle', |
|
52
|
|
|
], |
|
53
|
|
|
[ |
|
54
|
|
|
'namespace_prefix' => 'JMSSerializerBundleNs2', |
|
55
|
|
|
'path' => '@JMSSerializerBundle/Resources/config', |
|
56
|
|
|
], |
|
57
|
|
|
] |
|
58
|
|
|
] |
|
59
|
|
|
], |
|
60
|
|
|
]); |
|
61
|
|
|
|
|
62
|
|
|
$directories = $container->getDefinition('jms_serializer.metadata.file_locator')->getArgument(0); |
|
63
|
|
|
|
|
64
|
|
|
$this->assertEquals($ref->getPath(), $directories['JMSSerializerBundleNs1']); |
|
65
|
|
|
$this->assertEquals($ref->getPath().'/Resources/config', $directories['JMSSerializerBundleNs2']); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|