|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sonata Project package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sonata\AdminBundle\Tests\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; |
|
15
|
|
|
use Sonata\AdminBundle\DependencyInjection\SonataAdminExtension; |
|
16
|
|
|
|
|
17
|
|
|
class SonataAdminExtensionTest extends AbstractExtensionTestCase |
|
18
|
|
|
{ |
|
19
|
|
|
public function testHasServiceDefinitionForLockExtension() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->container->setParameter('kernel.bundles', []); |
|
22
|
|
|
$this->load(['options' => ['lock_protection' => true]]); |
|
23
|
|
|
$this->assertContainerBuilderHasService('sonata.admin.lock.extension'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testNotHasServiceDefinitionForLockExtension() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->container->setParameter('kernel.bundles', []); |
|
29
|
|
|
$this->load(['options' => ['lock_protection' => false]]); |
|
30
|
|
|
$this->assertContainerBuilderNotHasService('sonata.admin.lock.extension'); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function testLoadsExporterServiceDefinitionWhenExporterBundleIsRegistered() |
|
34
|
|
|
{ |
|
35
|
|
|
$this->container->setParameter('kernel.bundles', ['SonataExporterBundle' => 'whatever']); |
|
36
|
|
|
$this->load(); |
|
37
|
|
|
$this->assertContainerBuilderHasService( |
|
38
|
|
|
'sonata.admin.admin_exporter', |
|
39
|
|
|
'Sonata\AdminBundle\Bridge\Exporter\AdminExporter' |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testHasSecurityRoleParameters() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->container->setParameter('kernel.bundles', []); |
|
46
|
|
|
$this->load(); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertContainerBuilderHasParameter('sonata.admin.configuration.security.role_admin'); |
|
49
|
|
|
$this->assertContainerBuilderHasParameter('sonata.admin.configuration.security.role_super_admin'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
protected function getContainerExtensions() |
|
53
|
|
|
{ |
|
54
|
|
|
return [new SonataAdminExtension()]; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|