/
HttpBasicPreAuthenticatedFactoryTest.php
30 lines (24 loc) · 1.41 KB
/
HttpBasicPreAuthenticatedFactoryTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace OpenSky\Bundle\LdapBundle\Tests\DependencyInjection\Security;
use OpenSky\Bundle\LdapBundle\DependencyInjection\Security\HttpBasicPreAuthenticatedFactory;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
class HttpBasicPreAuthenticatedFactoryTest extends \PHPUnit_Framework_TestCase
{
public function testCreate()
{
$factory = new HttpBasicPreAuthenticatedFactory();
$container = new ContainerBuilder();
$userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
$defaultEntryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface');
// Load "security.authentication.listener.basic_pre_auth.class" parameter from ldap.xml
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config'));
$loader->load('ldap.xml');
list($provider, $listenerId, $returnedDefaultEntryPoint) = $factory->create($container, rand(), array(), $userProvider, $defaultEntryPoint);
$this->assertTrue($container->hasDefinition($provider));
$this->assertTrue($container->hasDefinition($listenerId));
$this->assertSame($defaultEntryPoint, $returnedDefaultEntryPoint);
}
}