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
|
|
|
* Class InMemoryApiFactoryTest |
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
|
|
|
|
34
|
|
|
public function testCreate() |
35
|
|
|
{ |
36
|
|
|
$container = new ContainerBuilder(); |
37
|
|
|
$inMemoryApiFactory = new InMemoryApiFactory(); |
38
|
|
|
|
39
|
|
|
$inMemoryApiFactory->create($container, 'oslab', $this->users); |
40
|
|
|
|
41
|
|
|
$this->assertTrue(($container->hasDefinition('oslab') ?: $container->hasAlias('oslab'))); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testKey() |
45
|
|
|
{ |
46
|
|
|
$inMemoryApiFactory = new InMemoryApiFactory(); |
47
|
|
|
|
48
|
|
|
$key = $inMemoryApiFactory->getKey(); |
49
|
|
|
|
50
|
|
|
$this->assertEquals($key, 'memory_api'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testAddConfiguration() |
54
|
|
|
{ |
55
|
|
|
$inMemoryApiFactory = new InMemoryApiFactory(); |
56
|
|
|
$nodeDefinition = new ArrayNodeDefinition('oslab'); |
57
|
|
|
|
58
|
|
|
$inMemoryApiFactory->addConfiguration($nodeDefinition); |
59
|
|
|
|
60
|
|
|
$this->assertArrayHasKey('users', $nodeDefinition->getNode()->finalize(['users'])); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|