0
0
mirror of https://github.com/kevinpapst/kimai2.git synced 2024-12-22 12:18:29 +00:00
kevinpapst_kimai2/tests/Configuration/LdapConfigurationTest.php
2024-12-22 01:25:30 +01:00

63 lines
1.7 KiB
PHP

<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Configuration;
use App\Configuration\LdapConfiguration;
use App\Tests\Mocks\SystemConfigurationFactory;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Configuration\LdapConfiguration
* @covers \App\Configuration\SystemConfiguration
*/
class LdapConfigurationTest extends TestCase
{
protected function getSut(array $settings)
{
$systemConfig = SystemConfigurationFactory::create(new TestConfigLoader([]), ['ldap' => $settings]);
return new LdapConfiguration($systemConfig);
}
protected function getDefaultSettings()
{
return [
'activate' => true,
'connection' => [
'host' => '1.2.3.4',
],
'user' => [
'foo' => 'bar',
],
'role' => [
'bar' => 'foo',
],
];
}
public function testDefault(): void
{
$sut = $this->getSut([]);
self::assertFalse($sut->isActivated());
self::assertEquals([], $sut->getUserParameters());
self::assertEquals([], $sut->getRoleParameters());
self::assertEquals([], $sut->getConnectionParameters());
}
public function testMapping(): void
{
$sut = $this->getSut($this->getDefaultSettings());
self::assertTrue($sut->isActivated());
self::assertEquals(['foo' => 'bar'], $sut->getUserParameters());
self::assertEquals(['bar' => 'foo'], $sut->getRoleParameters());
self::assertEquals(['host' => '1.2.3.4'], $sut->getConnectionParameters());
}
}