new user-year reporting and data-type chooser (#3155)
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
61
tests/Reporting/AbstractUserListTest.php
Normal file
61
tests/Reporting/AbstractUserListTest.php
Normal 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');
|
||||
}
|
||||
}
|
||||
25
tests/Reporting/MonthlyUserListTest.php
Normal file
25
tests/Reporting/MonthlyUserListTest.php
Normal 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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
25
tests/Reporting/WeeklyUserListTest.php
Normal file
25
tests/Reporting/WeeklyUserListTest.php
Normal 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();
|
||||
}
|
||||
}
|
||||
25
tests/Reporting/YearByUserTest.php
Normal file
25
tests/Reporting/YearByUserTest.php
Normal 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();
|
||||
}
|
||||
}
|
||||
25
tests/Reporting/YearlyUserListTest.php
Normal file
25
tests/Reporting/YearlyUserListTest.php
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user