added project detail report (#2651)
- avatars via css only - random colors for entities - improves print view - added colors for teams - added color to tag
This commit is contained in:
79
tests/Model/AbstractTimesheetCountedStatisticTest.php
Normal file
79
tests/Model/AbstractTimesheetCountedStatisticTest.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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;
|
||||
|
||||
use App\Model\TimesheetCountedStatistic;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class AbstractTimesheetCountedStatisticTest extends TestCase
|
||||
{
|
||||
protected function assertDefaultValues(TimesheetCountedStatistic $sut)
|
||||
{
|
||||
self::assertSame(0.0, $sut->getRecordRate());
|
||||
self::assertSame(0.0, $sut->getRate());
|
||||
self::assertSame(0, $sut->getRecordDuration());
|
||||
self::assertSame(0, $sut->getDuration());
|
||||
self::assertSame(0, $sut->getRecordAmount());
|
||||
self::assertSame(0.0, $sut->getRecordInternalRate());
|
||||
self::assertSame(0, $sut->getValue());
|
||||
self::assertSame(0, $sut->getDurationBillable());
|
||||
self::assertSame(0.0, $sut->getRateBillable());
|
||||
self::assertSame(0, $sut->getRecordAmountBillable());
|
||||
}
|
||||
|
||||
protected function assertSetter(TimesheetCountedStatistic $sut)
|
||||
{
|
||||
self::assertInstanceOf(TimesheetCountedStatistic::class, $sut->setRecordRate(23.97));
|
||||
self::assertInstanceOf(TimesheetCountedStatistic::class, $sut->setRecordDuration(21));
|
||||
self::assertInstanceOf(TimesheetCountedStatistic::class, $sut->setRecordAmount(5));
|
||||
self::assertInstanceOf(TimesheetCountedStatistic::class, $sut->setRecordInternalRate(99.09));
|
||||
|
||||
self::assertSame(23.97, $sut->getRecordRate());
|
||||
self::assertSame(23.97, $sut->getRate());
|
||||
self::assertSame(21, $sut->getRecordDuration());
|
||||
self::assertSame(21, $sut->getDuration());
|
||||
self::assertSame(21, $sut->getValue());
|
||||
self::assertSame(5, $sut->getRecordAmount());
|
||||
self::assertSame(99.09, $sut->getRecordInternalRate());
|
||||
|
||||
$sut->setRateBillable(123.456);
|
||||
$sut->setDurationBillable(1234);
|
||||
$sut->setRecordAmountBillable(4321);
|
||||
|
||||
self::assertSame(123.456, $sut->getRateBillable());
|
||||
self::assertSame(1234, $sut->getDurationBillable());
|
||||
self::assertSame(4321, $sut->getRecordAmountBillable());
|
||||
}
|
||||
|
||||
protected function assertJsonSerialize(TimesheetCountedStatistic $sut)
|
||||
{
|
||||
self::assertInstanceOf(\JsonSerializable::class, $sut);
|
||||
$sut->setRecordRate(23.97);
|
||||
$sut->setRecordDuration(21);
|
||||
$sut->setRecordAmount(5);
|
||||
$sut->setRecordInternalRate(99.09);
|
||||
$sut->setRateBillable(123.456);
|
||||
$sut->setDurationBillable(1234);
|
||||
$sut->setRecordAmountBillable(4321);
|
||||
|
||||
$json = $sut->jsonSerialize();
|
||||
foreach (['duration', 'duration_billable', 'rate', 'rate_billable', 'rate_internal', 'amount', 'amount_billable'] as $key) {
|
||||
self::assertArrayHasKey($key, $json);
|
||||
}
|
||||
|
||||
self::assertSame(21, $json['duration']);
|
||||
self::assertSame(1234, $json['duration_billable']);
|
||||
self::assertSame(23.97, $json['rate']);
|
||||
self::assertSame(123.456, $json['rate_billable']);
|
||||
self::assertSame(99.09, $json['rate_internal']);
|
||||
self::assertSame(5, $json['amount']);
|
||||
self::assertSame(4321, $json['amount_billable']);
|
||||
}
|
||||
}
|
||||
@@ -9,28 +9,51 @@
|
||||
|
||||
namespace App\Tests\Model;
|
||||
|
||||
use App\Entity\Activity;
|
||||
use App\Model\ActivityStatistic;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\ActivityStatistic
|
||||
*/
|
||||
class ActivityStatisticTest extends TestCase
|
||||
class ActivityStatisticTest extends AbstractTimesheetCountedStatisticTest
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new ActivityStatistic();
|
||||
$this->assertEquals(0, $sut->getRecordAmount());
|
||||
$this->assertEquals(0, $sut->getRecordDuration());
|
||||
$this->assertDefaultValues(new ActivityStatistic());
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new ActivityStatistic();
|
||||
$sut->setRecordAmount(7654);
|
||||
$sut->setRecordDuration(826);
|
||||
$this->assertSetter(new ActivityStatistic());
|
||||
}
|
||||
|
||||
$this->assertEquals(7654, $sut->getRecordAmount());
|
||||
$this->assertEquals(826, $sut->getRecordDuration());
|
||||
public function testJsonSerialize()
|
||||
{
|
||||
$this->assertJsonSerialize(new ActivityStatistic());
|
||||
}
|
||||
|
||||
public function testAdditionalSetter()
|
||||
{
|
||||
$sut = new ActivityStatistic();
|
||||
self::assertNull($sut->getActivity());
|
||||
self::assertNull($sut->getColor());
|
||||
self::assertNull($sut->getName());
|
||||
|
||||
$activity = new Activity();
|
||||
$sut->setActivity($activity);
|
||||
$this->assertEquals($activity, $sut->getActivity());
|
||||
|
||||
self::assertNull($sut->getColor());
|
||||
self::assertNull($sut->getName());
|
||||
|
||||
$activity->setName('FOO');
|
||||
self::assertEquals('FOO', $sut->getName());
|
||||
|
||||
$activity->setColor('#000000');
|
||||
self::assertEquals('#000000', $sut->getColor());
|
||||
|
||||
$json = $sut->jsonSerialize();
|
||||
self::assertEquals('FOO', $json['name']);
|
||||
self::assertEquals('#000000', $json['color']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,33 +10,37 @@
|
||||
namespace App\Tests\Model;
|
||||
|
||||
use App\Model\CustomerStatistic;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\CustomerStatistic
|
||||
*/
|
||||
class CustomerStatisticTest extends TestCase
|
||||
class CustomerStatisticTest extends AbstractTimesheetCountedStatisticTest
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new CustomerStatistic();
|
||||
$this->assertEquals(0, $sut->getActivityAmount());
|
||||
$this->assertEquals(0, $sut->getProjectAmount());
|
||||
$this->assertEquals(0, $sut->getRecordAmount());
|
||||
$this->assertEquals(0, $sut->getRecordDuration());
|
||||
$this->assertDefaultValues(new CustomerStatistic());
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new CustomerStatistic();
|
||||
$sut->setRecordAmount(7654);
|
||||
$sut->setRecordDuration(826);
|
||||
$sut->setActivityAmount(13);
|
||||
$sut->setProjectAmount(2);
|
||||
$this->assertSetter(new CustomerStatistic());
|
||||
}
|
||||
|
||||
$this->assertEquals(13, $sut->getActivityAmount());
|
||||
$this->assertEquals(2, $sut->getProjectAmount());
|
||||
$this->assertEquals(7654, $sut->getRecordAmount());
|
||||
$this->assertEquals(826, $sut->getRecordDuration());
|
||||
public function testJsonSerialize()
|
||||
{
|
||||
$this->assertJsonSerialize(new CustomerStatistic());
|
||||
}
|
||||
|
||||
public function testAdditionalSetter()
|
||||
{
|
||||
$sut = new CustomerStatistic();
|
||||
|
||||
self::assertEquals(0, $sut->getActivityAmount());
|
||||
$sut->setActivityAmount(13);
|
||||
self::assertEquals(13, $sut->getActivityAmount());
|
||||
|
||||
self::assertEquals(0, $sut->getProjectAmount());
|
||||
$sut->setProjectAmount(2);
|
||||
self::assertEquals(2, $sut->getProjectAmount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,31 +9,35 @@
|
||||
|
||||
namespace App\Tests\Model;
|
||||
|
||||
use App\Model\CustomerStatistic;
|
||||
use App\Model\ProjectStatistic;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\ProjectStatistic
|
||||
*/
|
||||
class ProjectStatisticTest extends TestCase
|
||||
class ProjectStatisticTest extends AbstractTimesheetCountedStatisticTest
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new ProjectStatistic();
|
||||
self::assertEquals(0, $sut->getActivityAmount());
|
||||
self::assertEquals(0, $sut->getRecordAmount());
|
||||
self::assertEquals(0, $sut->getRecordDuration());
|
||||
$this->assertDefaultValues(new CustomerStatistic());
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new ProjectStatistic();
|
||||
$sut->setRecordAmount(7654);
|
||||
$sut->setRecordDuration(826);
|
||||
$sut->setActivityAmount(13);
|
||||
$this->assertSetter(new CustomerStatistic());
|
||||
}
|
||||
|
||||
public function testJsonSerialize()
|
||||
{
|
||||
$this->assertJsonSerialize(new CustomerStatistic());
|
||||
}
|
||||
|
||||
public function testAdditionalSetter()
|
||||
{
|
||||
$sut = new ProjectStatistic();
|
||||
|
||||
self::assertEquals(0, $sut->getActivityAmount());
|
||||
$sut->setActivityAmount(13);
|
||||
self::assertEquals(13, $sut->getActivityAmount());
|
||||
self::assertEquals(7654, $sut->getRecordAmount());
|
||||
self::assertEquals(826, $sut->getRecordDuration());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,44 +10,24 @@
|
||||
namespace App\Tests\Model;
|
||||
|
||||
use App\Model\TimesheetCountedStatistic;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\TimesheetCountedStatistic
|
||||
*/
|
||||
class TimesheetCountedStatisticTest extends TestCase
|
||||
class TimesheetCountedStatisticTest extends AbstractTimesheetCountedStatisticTest
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new TimesheetCountedStatistic();
|
||||
self::assertSame(0.0, $sut->getRecordRate());
|
||||
self::assertSame(0, $sut->getRecordDuration());
|
||||
self::assertSame(0, $sut->getRecordAmount());
|
||||
self::assertSame(0.0, $sut->getRecordInternalRate());
|
||||
self::assertSame(0, $sut->getDurationBillable());
|
||||
self::assertSame(0.0, $sut->getRateBillable());
|
||||
self::assertSame(0, $sut->getRecordAmountBillable());
|
||||
$this->assertDefaultValues(new TimesheetCountedStatistic());
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new TimesheetCountedStatistic();
|
||||
self::assertInstanceOf(TimesheetCountedStatistic::class, $sut->setRecordRate(23.97));
|
||||
self::assertInstanceOf(TimesheetCountedStatistic::class, $sut->setRecordDuration(21));
|
||||
self::assertInstanceOf(TimesheetCountedStatistic::class, $sut->setRecordAmount(5));
|
||||
self::assertInstanceOf(TimesheetCountedStatistic::class, $sut->setRecordInternalRate(99.09));
|
||||
$this->assertSetter(new TimesheetCountedStatistic());
|
||||
}
|
||||
|
||||
self::assertSame(23.97, $sut->getRecordRate());
|
||||
self::assertSame(21, $sut->getRecordDuration());
|
||||
self::assertSame(5, $sut->getRecordAmount());
|
||||
self::assertSame(99.09, $sut->getRecordInternalRate());
|
||||
|
||||
$sut->setRateBillable(123.456);
|
||||
$sut->setDurationBillable(1234);
|
||||
$sut->setRecordAmountBillable(4321);
|
||||
|
||||
self::assertSame(123.456, $sut->getRateBillable());
|
||||
self::assertSame(1234, $sut->getDurationBillable());
|
||||
self::assertSame(4321, $sut->getRecordAmountBillable());
|
||||
public function testJsonSerialize()
|
||||
{
|
||||
$this->assertJsonSerialize(new TimesheetCountedStatistic());
|
||||
}
|
||||
}
|
||||
|
||||
38
tests/Model/UserStatisticTest.php
Normal file
38
tests/Model/UserStatisticTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Model\ActivityStatistic;
|
||||
use App\Model\UserStatistic;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\UserStatistic
|
||||
*/
|
||||
class UserStatisticTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$user = new User();
|
||||
$sut = new UserStatistic($user);
|
||||
$this->assertEquals(0, $sut->getRecordRate());
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new ActivityStatistic();
|
||||
$sut->setRecordAmount(7654);
|
||||
$sut->setRecordDuration(826);
|
||||
|
||||
$this->assertEquals(7654, $sut->getRecordAmount());
|
||||
$this->assertEquals(826, $sut->getRecordDuration());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user