Files
kimai2/tests/Entity/TagTest.php
Kevin Papst afb5a0bba4 Release 2.45 (#5721)
Co-authored-by: Henning Klein <info@henningklein.de>
2025-12-21 16:42:34 +01:00

47 lines
1.3 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\Entity;
use App\Entity\Tag;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
#[CoversClass(Tag::class)]
class TagTest extends TestCase
{
public function testDefaultValues(): void
{
$sut = new Tag();
self::assertNull($sut->getId());
self::assertNull($sut->getName());
self::assertNull($sut->getColor());
}
public function testSetterAndGetter(): void
{
$sut = new Tag();
self::assertIsString($sut->getColorSafe());
self::assertInstanceOf(Tag::class, $sut->setName('foo'));
self::assertEquals('foo', $sut->getName());
self::assertEquals('foo', (string) $sut);
self::assertEquals('#e135f4', $sut->getColorSafe());
$sut->setName(null);
self::assertNull($sut->getName());
self::assertNull($sut->getColor());
self::assertIsString($sut->getColorSafe());
$sut->setColor('#fffccc');
self::assertEquals('#fffccc', $sut->getColor());
self::assertEquals('#fffccc', $sut->getColorSafe());
}
}