Files
kimai2/tests/Event/ThemeEventTest.php
Kevin Papst 4b2a3669e6 Release 2.0.19 (#4022)
* prevent invoices with exceeding filename
* fixed invalid LDAP log level
* support locale switching in action events
2023-05-12 14:45:51 +02:00

72 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\Event;
use App\Entity\User;
use App\Event\ThemeEvent;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Event\ThemeEvent
*/
class ThemeEventTest extends TestCase
{
public function testEmpty(): void
{
$sut = new ThemeEvent();
$this->assertNull($sut->getUser());
$this->assertNull($sut->getPayload());
$this->assertEquals('', $sut->getContent());
}
public function testDefaultValues(): void
{
$user = new User();
$user->setAlias('foo');
$sut = new ThemeEvent($user);
$this->assertSame($user, $sut->getUser());
}
public function testGetterAndSetter(): void
{
$user = new User();
$user->setAlias('foo');
$payload = [null, '', 'test', new \stdClass()];
$sut = new ThemeEvent($user, $payload);
$this->assertEquals($payload, $sut->getPayload());
$sut = new ThemeEvent($user);
$sut->addContent('foo');
$this->assertEquals('foo', $sut->getContent());
$sut->addContent('<script>');
$this->assertEquals('foo<script>', $sut->getContent());
}
/**
* @group legacy
*/
public function testDeprecatedStuff(): void
{
$user = new User();
$user->setAlias('foo');
$payload = [null, '', 'test', new \stdClass()];
$sut = new ThemeEvent($user);
$sut->setPayload($payload);
$this->assertEquals($payload, $sut->getPayload());
}
}