InMemoryApiFactoryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 40
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreate() 0 9 2
A testKey() 0 8 1
A testAddConfiguration() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the SecurityApiBundle package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace OsLab\SecurityApiBundle\Tests\User;
11
12
use OsLab\SecurityApiBundle\DependencyInjection\Security\UserProvider\InMemoryApiFactory;
13
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
16
/**
17
 * Unit test for the InMemoryApiFactory.
18
 *
19
 * @author Michael COULLERET <[email protected]>
20
 * @author Florent DESPIERRES <[email protected]>
21
 */
22
class InMemoryApiFactoryTest extends \PHPUnit_Framework_TestCase
23
{
24
    protected $users = [
25
        'users' => [
26
            'user' => [
27
                'password' => 'abc',
28
                'roles' => ['ROLE_USER'],
29
            ],
30
        ],
31
    ];
32
33
    public function testCreate()
34
    {
35
        $container = new ContainerBuilder();
36
        $inMemoryApiFactory = new InMemoryApiFactory();
37
38
        $inMemoryApiFactory->create($container, 'oslab', $this->users);
39
40
        $this->assertTrue(($container->hasDefinition('oslab') ?: $container->hasAlias('oslab')));
41
    }
42
43
    public function testKey()
44
    {
45
        $inMemoryApiFactory = new InMemoryApiFactory();
46
47
        $key = $inMemoryApiFactory->getKey();
48
49
        $this->assertSame($key, 'memory_api');
50
    }
51
52
    public function testAddConfiguration()
53
    {
54
        $inMemoryApiFactory = new InMemoryApiFactory();
55
        $nodeDefinition = new ArrayNodeDefinition('oslab');
56
57
        $inMemoryApiFactory->addConfiguration($nodeDefinition);
58
59
        $this->assertArrayHasKey('users', $nodeDefinition->getNode()->finalize(['users']));
60
    }
61
}
62