fix LDAP install for systems without ldap extension (#846)
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
|
||||
namespace App\Tests\Ldap;
|
||||
|
||||
use App\Configuration\LdapConfiguration;
|
||||
use App\Entity\User;
|
||||
use App\Ldap\LdapManager;
|
||||
use App\Ldap\LdapUserProvider;
|
||||
@@ -20,41 +19,6 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class LdapUserProviderTest extends TestCase
|
||||
{
|
||||
public function testDeactivatedSupportsClass()
|
||||
{
|
||||
$manager = $this->getMockBuilder(LdapManager::class)->disableOriginalConstructor()->getMock();
|
||||
$config = new LdapConfiguration(['active' => false]);
|
||||
|
||||
$sut = new LdapUserProvider($manager, $config);
|
||||
self::assertFalse($sut->supportsClass(User::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
|
||||
* @expectedExceptionMessage LDAP is deactivated, user "test" not searched
|
||||
*/
|
||||
public function testDeactivatedLoadUserByUsername()
|
||||
{
|
||||
$manager = $this->getMockBuilder(LdapManager::class)->disableOriginalConstructor()->getMock();
|
||||
$config = new LdapConfiguration(['active' => false]);
|
||||
|
||||
$sut = new LdapUserProvider($manager, $config);
|
||||
$sut->loadUserByUsername('test');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Security\Core\Exception\UnsupportedUserException
|
||||
* @expectedExceptionMessage Instances of "App\Entity\User" are not supported.
|
||||
*/
|
||||
public function testDeactivatedRefreshUser()
|
||||
{
|
||||
$manager = $this->getMockBuilder(LdapManager::class)->disableOriginalConstructor()->getMock();
|
||||
$config = new LdapConfiguration(['active' => false]);
|
||||
|
||||
$sut = new LdapUserProvider($manager, $config);
|
||||
$sut->refreshUser(new User());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
|
||||
* @expectedExceptionMessage User "test" not found
|
||||
@@ -63,9 +27,8 @@ class LdapUserProviderTest extends TestCase
|
||||
{
|
||||
$manager = $this->getMockBuilder(LdapManager::class)->disableOriginalConstructor()->setMethods(['findUserByUsername'])->getMock();
|
||||
$manager->expects($this->once())->method('findUserByUsername')->willReturn(null);
|
||||
$config = new LdapConfiguration(['active' => true]);
|
||||
|
||||
$sut = new LdapUserProvider($manager, $config);
|
||||
$sut = new LdapUserProvider($manager);
|
||||
$sut->loadUserByUsername('test');
|
||||
}
|
||||
|
||||
@@ -76,9 +39,8 @@ class LdapUserProviderTest extends TestCase
|
||||
|
||||
$manager = $this->getMockBuilder(LdapManager::class)->disableOriginalConstructor()->setMethods(['findUserByUsername'])->getMock();
|
||||
$manager->expects($this->once())->method('findUserByUsername')->willReturn($user);
|
||||
$config = new LdapConfiguration(['active' => true]);
|
||||
|
||||
$sut = new LdapUserProvider($manager, $config);
|
||||
$sut = new LdapUserProvider($manager);
|
||||
$actual = $sut->loadUserByUsername('test');
|
||||
self::assertInstanceOf(User::class, $actual);
|
||||
self::assertSame($user, $actual);
|
||||
@@ -91,9 +53,8 @@ class LdapUserProviderTest extends TestCase
|
||||
$user->setPreferenceValue('ldap.dn', 'sdfdsf');
|
||||
|
||||
$manager = $this->getMockBuilder(LdapManager::class)->disableOriginalConstructor()->setMethods(['updateUser'])->getMock();
|
||||
$config = new LdapConfiguration(['active' => true]);
|
||||
|
||||
$sut = new LdapUserProvider($manager, $config);
|
||||
$sut = new LdapUserProvider($manager);
|
||||
$actual = $sut->refreshUser($user);
|
||||
|
||||
self::assertInstanceOf(User::class, $actual);
|
||||
|
||||
Reference in New Issue
Block a user