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
|
|
|
|