monthly budget, monthly report, unified report calculation (#2684)
This commit is contained in:
42
tests/Model/Statistic/AbstractTimesheetTest.php
Normal file
42
tests/Model/Statistic/AbstractTimesheetTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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\Model\Statistic;
|
||||
|
||||
use App\Model\Statistic\Timesheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class AbstractTimesheetTest extends TestCase
|
||||
{
|
||||
protected function assertDefaultValues(Timesheet $sut)
|
||||
{
|
||||
self::assertSame(0.0, $sut->getRate());
|
||||
self::assertSame(0, $sut->getDuration());
|
||||
self::assertSame(0, $sut->getValue());
|
||||
self::assertSame(0.0, $sut->getInternalRate());
|
||||
self::assertSame(0, $sut->getTotalDuration());
|
||||
self::assertSame(0.0, $sut->getTotalRate());
|
||||
self::assertSame(0.0, $sut->getTotalInternalRate());
|
||||
}
|
||||
|
||||
protected function assertSetter(Timesheet $sut)
|
||||
{
|
||||
$sut->setTotalInternalRate(5485.84);
|
||||
$sut->setTotalRate(1234.23);
|
||||
$sut->setTotalDuration(567);
|
||||
|
||||
self::assertSame(1234.23, $sut->getRate());
|
||||
self::assertSame(567, $sut->getDuration());
|
||||
self::assertSame(567, $sut->getValue());
|
||||
self::assertSame(5485.84, $sut->getInternalRate());
|
||||
self::assertSame(567, $sut->getTotalDuration());
|
||||
self::assertSame(1234.23, $sut->getTotalRate());
|
||||
self::assertSame(5485.84, $sut->getTotalInternalRate());
|
||||
}
|
||||
}
|
||||
34
tests/Model/Statistic/BudgetStatisticTest.php
Normal file
34
tests/Model/Statistic/BudgetStatisticTest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\Model\Statistic;
|
||||
|
||||
use App\Model\Statistic\BudgetStatistic;
|
||||
use App\Tests\Model\AbstractTimesheetCountedStatisticTest;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\Statistic\BudgetStatistic
|
||||
*/
|
||||
class BudgetStatisticTest extends AbstractTimesheetCountedStatisticTest
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$this->assertDefaultValues(new BudgetStatistic());
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$this->assertSetter(new BudgetStatistic());
|
||||
}
|
||||
|
||||
public function testJsonSerialize()
|
||||
{
|
||||
$this->assertJsonSerialize(new BudgetStatistic());
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,26 @@ namespace App\Tests\Model\Statistic;
|
||||
|
||||
use App\Model\Statistic\Day;
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\Statistic\Day
|
||||
*/
|
||||
class DayTest extends TestCase
|
||||
class DayTest extends AbstractTimesheetTest
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$date = new DateTime('-8 hours');
|
||||
$sut = new Day($date, 0, 0.0);
|
||||
$this->assertDefaultValues($sut);
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$date = new DateTime('-8 hours');
|
||||
$sut = new Day($date, 12340, 197.25956);
|
||||
$this->assertSetter($sut);
|
||||
}
|
||||
|
||||
public function testConstruct()
|
||||
{
|
||||
$date = new DateTime('-8 hours');
|
||||
|
||||
@@ -11,16 +11,17 @@ namespace App\Tests\Model\Statistic;
|
||||
|
||||
use App\Model\Statistic\Month;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\Statistic\Month
|
||||
*/
|
||||
class MonthTest extends TestCase
|
||||
class MonthTest extends AbstractTimesheetTest
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new Month('01');
|
||||
$this->assertDefaultValues($sut);
|
||||
|
||||
self::assertSame('01', $sut->getMonth());
|
||||
self::assertSame(0, $sut->getTotalDuration());
|
||||
self::assertSame(0.0, $sut->getTotalRate());
|
||||
@@ -88,6 +89,8 @@ class MonthTest extends TestCase
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new Month('01');
|
||||
$this->assertSetter($sut);
|
||||
|
||||
$sut->setTotalDuration(999);
|
||||
$sut->setTotalRate(0.123456789);
|
||||
$sut->setBillableDuration(123456);
|
||||
|
||||
49
tests/Model/Statistic/StatisticDateTest.php
Normal file
49
tests/Model/Statistic/StatisticDateTest.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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\Model\Statistic;
|
||||
|
||||
use App\Model\Statistic\StatisticDate;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\Statistic\StatisticDate
|
||||
*/
|
||||
class StatisticDateTest extends AbstractTimesheetTest
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$dateTime = new \DateTime('-8 hours');
|
||||
$sut = new StatisticDate($dateTime);
|
||||
$this->assertDefaultValues($sut);
|
||||
self::assertSame(0.0, $sut->getBillableRate());
|
||||
self::assertSame(0, $sut->getBillableDuration());
|
||||
self::assertNotSame($dateTime, $sut->getDate());
|
||||
self::assertEquals($dateTime->getTimestamp(), $sut->getDate()->getTimestamp());
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$date = new DateTime('-8 hours');
|
||||
$sut = new StatisticDate($date);
|
||||
$this->assertSetter($sut);
|
||||
}
|
||||
|
||||
public function testAdditionalMethods()
|
||||
{
|
||||
$date = new DateTime('-8 hours');
|
||||
$sut = new StatisticDate($date);
|
||||
|
||||
$sut->setBillableRate(4869.38);
|
||||
self::assertSame(4869.38, $sut->getBillableRate());
|
||||
|
||||
$sut->setBillableDuration(512376);
|
||||
self::assertSame(512376, $sut->getBillableDuration());
|
||||
}
|
||||
}
|
||||
30
tests/Model/Statistic/TimesheetTest.php
Normal file
30
tests/Model/Statistic/TimesheetTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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\Model\Statistic;
|
||||
|
||||
use App\Model\Statistic\Timesheet;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\Statistic\Timesheet
|
||||
*/
|
||||
class TimesheetTest extends AbstractTimesheetTest
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new Timesheet();
|
||||
$this->assertDefaultValues($sut);
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new Timesheet();
|
||||
$this->assertSetter($sut);
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,17 @@ namespace App\Tests\Model\Statistic;
|
||||
|
||||
use App\Model\Statistic\Month;
|
||||
use App\Model\Statistic\Year;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\Statistic\Year
|
||||
*/
|
||||
class YearTest extends TestCase
|
||||
class YearTest extends AbstractTimesheetTest
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new Year('1999');
|
||||
$this->assertDefaultValues($sut);
|
||||
|
||||
self::assertNull($sut->getMonth(1));
|
||||
self::assertEmpty($sut->getMonths());
|
||||
self::assertIsArray($sut->getMonths());
|
||||
@@ -30,6 +31,7 @@ class YearTest extends TestCase
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new Year('1999');
|
||||
$this->assertSetter($sut);
|
||||
|
||||
$sut->setMonth(new Month('01'));
|
||||
$sut->setMonth(new Month('02'));
|
||||
|
||||
Reference in New Issue
Block a user