new user-year reporting and data-type chooser (#3155)

This commit is contained in:
Kevin Papst
2022-02-16 12:18:04 +01:00
committed by GitHub
parent 1852d71974
commit 85a63c4b78
58 changed files with 1862 additions and 683 deletions

View File

@@ -14,6 +14,7 @@ use App\Reporting\DateByUser;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Reporting\AbstractUserList
* @covers \App\Reporting\DateByUser
*/
abstract class AbstractDateByUserTest extends TestCase
@@ -25,6 +26,8 @@ abstract class AbstractDateByUserTest extends TestCase
$sut = $this->createSut();
self::assertNull($sut->getDate());
self::assertNull($sut->getUser());
self::assertEquals('duration', $sut->getSumType());
self::assertFalse($sut->isDecimal());
}
public function testSetter()
@@ -34,10 +37,32 @@ abstract class AbstractDateByUserTest extends TestCase
$user->setAlias('sdfsdfdsdf');
$sut = $this->createSut();
self::assertInstanceOf(DateByUser::class, $sut->setDate($date));
self::assertInstanceOf(DateByUser::class, $sut->setUser($user));
$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()
{
$this->expectException(\InvalidArgumentException::class);
$sut = $this->createSut();
$sut->setSumType('DURation');
}
}

View File

@@ -0,0 +1,61 @@
<?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\Reporting\AbstractUserList;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Reporting\AbstractUserList
*/
abstract class AbstractUserListTest extends TestCase
{
abstract protected function createSut(): AbstractUserList;
public function testEmptyObject()
{
$sut = $this->createSut();
self::assertNull($sut->getDate());
self::assertEquals('duration', $sut->getSumType());
self::assertFalse($sut->isDecimal());
}
public function testSetter()
{
$date = new \DateTime('2019-05-27');
$sut = $this->createSut();
$sut->setDate($date);
self::assertSame($date, $sut->getDate());
$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()
{
$this->expectException(\InvalidArgumentException::class);
$sut = $this->createSut();
$sut->setSumType('DURation');
}
}

View File

@@ -0,0 +1,25 @@
<?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\Reporting\AbstractUserList;
use App\Reporting\MonthlyUserList;
/**
* @covers \App\Reporting\MonthlyUserList
* @covers \App\Reporting\AbstractUserList
*/
class MonthlyUserListTest extends AbstractUserListTest
{
protected function createSut(): AbstractUserList
{
return new MonthlyUserList();
}
}

View File

@@ -47,6 +47,6 @@ class ReportingServiceTest extends TestCase
$sut = $this->getSut(true);
$reports = $sut->getAvailableReports(new User());
self::assertIsArray($reports);
self::assertCount(9, $reports);
self::assertCount(10, $reports);
}
}

View File

@@ -0,0 +1,25 @@
<?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\Reporting\AbstractUserList;
use App\Reporting\WeeklyUserList;
/**
* @covers \App\Reporting\WeeklyUserList
* @covers \App\Reporting\AbstractUserList
*/
class WeeklyUserListTest extends AbstractUserListTest
{
protected function createSut(): AbstractUserList
{
return new WeeklyUserList();
}
}

View File

@@ -0,0 +1,25 @@
<?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\Reporting\DateByUser;
use App\Reporting\YearByUser;
/**
* @covers \App\Reporting\YearByUser
* @covers \App\Reporting\DateByUser
*/
class YearByUserTest extends AbstractDateByUserTest
{
protected function createSut(): DateByUser
{
return new YearByUser();
}
}

View File

@@ -0,0 +1,25 @@
<?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\Reporting\AbstractUserList;
use App\Reporting\YearlyUserList;
/**
* @covers \App\Reporting\YearlyUserList
* @covers \App\Reporting\AbstractUserList
*/
class YearlyUserListTest extends AbstractUserListTest
{
protected function createSut(): AbstractUserList
{
return new YearlyUserList();
}
}