0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-01-11 11:58:10 +00:00
kevinpapst_kimai2/tests/Form/Model/SystemConfigurationTest.php
2024-02-07 23:47:25 +01:00

57 lines
1.8 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\Form\Model;
use App\Form\Model\Configuration;
use App\Form\Model\SystemConfiguration;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Form\Model\Configuration
* @covers \App\Form\Model\SystemConfiguration
*/
class SystemConfigurationTest extends TestCase
{
public function testDefaultValues(): void
{
$sut = new SystemConfiguration();
self::assertNull($sut->getSection());
self::assertEquals([], $sut->getConfiguration());
}
public function testSetterAndGetter(): void
{
$sut = new SystemConfiguration('foo');
self::assertEquals('foo', $sut->getSection());
self::assertInstanceOf(SystemConfiguration::class, $sut->setConfiguration([]));
self::assertEquals([], $sut->getConfiguration());
$config = new Configuration('1');
self::assertInstanceOf(SystemConfiguration::class, $sut->setConfiguration([$config]));
self::assertEquals([$config], $sut->getConfiguration());
self::assertInstanceOf(SystemConfiguration::class, $sut->setConfiguration([$config, $config]));
self::assertEquals([$config, $config], $sut->getConfiguration());
self::assertInstanceOf(SystemConfiguration::class, $sut->addConfiguration($config));
self::assertEquals([$config, $config, $config], $sut->getConfiguration());
$config = new Configuration('foo');
$sut->addConfiguration($config);
$config2 = new Configuration('bar');
$sut->addConfiguration($config2);
self::assertSame($config, $sut->getConfigurationByName('foo'));
self::assertNull($sut->getConfigurationByName('bar2'));
}
}