|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Superdesk Web Publisher MultiTenancy Bundle. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright 2016 Sourcefabric z.u. and contributors. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please see the |
|
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* @copyright 2016 Sourcefabric z.ú. |
|
12
|
|
|
* @license http://www.superdesk.org/license |
|
13
|
|
|
*/ |
|
14
|
|
|
namespace SWP\MultiTenancyBundle\Tests\DependencyInjection; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
17
|
|
|
use SWP\MultiTenancyBundle\DependencyInjection\SWPMultiTenancyExtension; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; |
|
19
|
|
|
|
|
20
|
|
|
class SWPMultiTenancyExtensionTest extends \PHPUnit_Framework_TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @covers SWP\MultiTenancyBundle\SWPMultiTenancyBundle |
|
24
|
|
|
* @covers SWP\MultiTenancyBundle\DependencyInjection\SWPMultiTenancyExtension::load |
|
25
|
|
|
* @covers SWP\MultiTenancyBundle\DependencyInjection\Configuration::getConfigTreeBuilder |
|
26
|
|
|
* @covers SWP\MultiTenancyBundle\DependencyInjection\SWPMultiTenancyExtension::loadPhpcr |
|
27
|
|
|
*/ |
|
28
|
|
|
public function testLoad() |
|
29
|
|
|
{ |
|
30
|
|
|
$container = $this->createContainer(); |
|
31
|
|
|
$loader = $this->createLoader(); |
|
32
|
|
|
$config = $this->getConfig(); |
|
33
|
|
|
|
|
34
|
|
|
$loader->load(array($config), $container); |
|
35
|
|
|
|
|
36
|
|
|
$this->assertTrue($container->getParameter('swp_multi_tenancy.backend_type_phpcr')); |
|
37
|
|
|
$this->assertEquals('/swp', $container->getParameter('swp_multi_tenancy.persistence.phpcr.basepath')); |
|
38
|
|
|
$this->assertEquals( |
|
39
|
|
|
'SWP\MultiTenancyBundle\Tests\Site', |
|
40
|
|
|
$container->getParameter('swp_multi_tenancy.persistence.phpcr.site_document.class') |
|
41
|
|
|
); |
|
42
|
|
|
$this->assertEquals('content', $container->getParameter('swp_multi_tenancy.persistence.phpcr.content_basepath')); |
|
43
|
|
|
$this->assertEquals( |
|
44
|
|
|
'SWP\MultiTenancyBundle\Routing\TenantAwareRouter', |
|
45
|
|
|
$container->getParameter('swp_multi_tenancy.persistence.phpcr.router.class') |
|
46
|
|
|
); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertEquals( |
|
49
|
|
|
array('routes1', 'routes2'), |
|
50
|
|
|
$container->getParameter('swp_multi_tenancy.persistence.phpcr.route_basepaths') |
|
51
|
|
|
); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertEquals( |
|
54
|
|
|
array('routes1', 'routes2', 'content'), |
|
55
|
|
|
$container->getParameter('swp_multi_tenancy.persistence.phpcr.base_paths') |
|
56
|
|
|
); |
|
57
|
|
|
|
|
58
|
|
|
$this->assertTrue($container->hasParameter('swp_multi_tenancy.backend_type_phpcr')); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function testLoadWhenPHPCRDisabled() |
|
62
|
|
|
{ |
|
63
|
|
|
$container = $this->createContainer(); |
|
64
|
|
|
$loader = $this->createLoader(); |
|
65
|
|
|
$config = $this->getConfig(); |
|
66
|
|
|
$config['persistence']['phpcr']['enabled'] = false; |
|
67
|
|
|
$loader->load(array($config), $container); |
|
68
|
|
|
|
|
69
|
|
|
$this->assertFalse($container->hasParameter('swp_multi_tenancy.backend_type_phpcr')); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
protected function createLoader() |
|
73
|
|
|
{ |
|
74
|
|
|
return new SWPMultiTenancyExtension(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
protected function getConfig() |
|
78
|
|
|
{ |
|
79
|
|
|
return array( |
|
80
|
|
|
'persistence' => array( |
|
81
|
|
|
'phpcr' => array( |
|
82
|
|
|
'enabled' => true, |
|
83
|
|
|
'content_basepath' => 'content', |
|
84
|
|
|
'site_document_class' => 'SWP\MultiTenancyBundle\Tests\Site', |
|
85
|
|
|
'route_basepaths' => array('routes1', 'routes2'), |
|
86
|
|
|
), |
|
87
|
|
|
), |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
protected function createContainer(array $data = array()) |
|
92
|
|
|
{ |
|
93
|
|
|
return new ContainerBuilder(new ParameterBag($data)); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|