Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -9,8 +9,10 @@
namespace App\Tests\Ldap;
use App\Configuration\LdapConfiguration;
use App\Entity\User;
use App\Ldap\LdapDriver;
use App\Tests\Mocks\SystemConfigurationFactory;
use Laminas\Ldap\Exception\LdapException;
use Laminas\Ldap\Ldap;
use PHPUnit\Framework\TestCase;
@@ -28,14 +30,26 @@ class LdapDriverTest extends TestCase
}
}
private function getTestLdapDriver(Ldap $ldap): TestLdapDriver
{
$config = SystemConfigurationFactory::createStub(['ldap' => [
'role' => [],
'user' => [],
'connection' => [],
]]);
return new TestLdapDriver(new LdapConfiguration($config), $ldap);
}
public function testBindSuccess()
{
$zendLdap = $this->getMockBuilder(Ldap::class)->disableOriginalConstructor()->onlyMethods(['bind'])->getMock();
$zendLdap->expects($this->once())->method('bind')->willReturnSelf();
$user = new User();
$sut = new TestLdapDriver($zendLdap);
$result = $sut->bind($user, 'test123');
$user->setUserIdentifier('foo');
$sut = $this->getTestLdapDriver($zendLdap);
$result = $sut->bind($user->getUserIdentifier(), 'test123');
self::assertTrue($result);
}
@@ -45,8 +59,9 @@ class LdapDriverTest extends TestCase
$zendLdap->expects($this->once())->method('bind')->willThrowException(new LdapException());
$user = new User();
$sut = new TestLdapDriver($zendLdap);
$result = $sut->bind($user, 'test123');
$user->setUserIdentifier('foo');
$sut = $this->getTestLdapDriver($zendLdap);
$result = $sut->bind($user->getUserIdentifier(), 'test123');
self::assertFalse($result);
}
@@ -56,7 +71,7 @@ class LdapDriverTest extends TestCase
$zendLdap->expects($this->once())->method('bind');
$zendLdap->expects($this->once())->method('searchEntries')->willReturn([1, 2, 3]);
$sut = new TestLdapDriver($zendLdap);
$sut = $this->getTestLdapDriver($zendLdap);
$result = $sut->search('', '', []);
self::assertEquals(['count' => 3, 1, 2, 3], $result);
}
@@ -64,14 +79,15 @@ class LdapDriverTest extends TestCase
class TestLdapDriver extends LdapDriver
{
private $testDriver;
private Ldap $testDriver;
public function __construct(Ldap $ldap)
public function __construct(LdapConfiguration $config, Ldap $ldap)
{
parent::__construct($config);
$this->testDriver = $ldap;
}
protected function getDriver()
protected function getDriver(): Ldap
{
return $this->testDriver;
}