CraftCampAbacExtensionTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 37
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testLoad() 0 12 1
A getConfigurationMock() 0 13 1
1
<?php
2
3
namespace CraftCamp\AbacBundle\Tests\DependencyInjection;
4
5
use CraftCamp\AbacBundle\DependencyInjection\CraftCampAbacExtension;
6
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
9
use PHPUnit\Framework\TestCase;
10
11
class CraftCampAbacExtensionTest extends TestCase
12
{
13
    /** @var CraftCampAbacExtension **/
14
    protected $extension;
15
    
16
    public function setUp()
17
    {
18
        $this->extension = new CraftCampAbacExtension();
19
    }
20
    
21
    public function testLoad()
22
    {
23
        $containerBuilder = new ContainerBuilder();
24
        
25
        $this->extension->load($this->getConfigurationMock(), $containerBuilder);
26
        
27
        $this->assertEquals($containerBuilder->getParameter('craftcamp_abac.configuration_files'), ['config/abac/policy_rules.yaml']);
28
        $this->assertEquals($containerBuilder->getParameter('craftcamp_abac.cache_options'), ['cache_folder' => '/var/cache']);
29
        $this->assertEquals($containerBuilder->getParameter('craftcamp_abac.attribute_options'), []);
30
        $this->assertTrue($containerBuilder->hasDefinition('PhpAbac\Abac'));
31
        $this->assertTrue($containerBuilder->hasAlias('craftcamp_abac.security'));
32
    }
33
34
    public function getConfigurationMock()
35
    {
36
        return [
37
            'craftcamp_abac' => [
38
                'configuration_files' => [
39
                    'config/abac/policy_rules.yaml'
40
                ],
41
                'cache_options' => [
42
                    'cache_folder' => '/var/cache'
43
                ]
44
            ]
45
        ];
46
    }
47
}