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

69 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\Reporting;
use App\Entity\User;
use App\Reporting\DateByUser;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Reporting\AbstractUserList
* @covers \App\Reporting\DateByUser
*/
abstract class AbstractDateByUserTestCase extends TestCase
{
abstract protected function createSut(): DateByUser;
public function testEmptyObject(): void
{
$sut = $this->createSut();
self::assertNull($sut->getDate());
self::assertNull($sut->getUser());
self::assertEquals('duration', $sut->getSumType());
self::assertFalse($sut->isDecimal());
}
public function testSetter(): void
{
$date = new \DateTime('2019-05-27');
$user = new User();
$user->setAlias('sdfsdfdsdf');
$sut = $this->createSut();
$sut->setDate($date);
$sut->setUser($user);
self::assertSame($date, $sut->getDate());
self::assertSame($user, $sut->getUser());
$sut->setSumType('rate');
self::assertEquals('rate', $sut->getSumType());
$sut->setSumType('internalRate');
self::assertEquals('internalRate', $sut->getSumType());
$sut->setSumType('duration');
self::assertEquals('duration', $sut->getSumType());
$sut->setDecimal(true);
self::assertTrue($sut->isDecimal());
$sut->setDecimal(false);
self::assertFalse($sut->isDecimal());
}
public function testInvalidSumType(): void
{
$this->expectException(\InvalidArgumentException::class);
$sut = $this->createSut();
$sut->setSumType('DURation');
}
}