users weekly stats as bar-chart in dashboard (#847)

This commit is contained in:
Kevin Papst
2019-06-13 18:38:49 +02:00
committed by GitHub
parent e1f862507e
commit 3311f17bbb
96 changed files with 2754 additions and 846 deletions

View 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\Day;
use DateTime;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Model\Statistic\Day
*/
class DayTest extends TestCase
{
public function testConstruct()
{
$date = new DateTime('-8 hours');
$sut = new Day($date, 12340, 197.25956);
$this->assertSame($date, $sut->getDay());
$this->assertEquals(12340, $sut->getTotalDuration());
$this->assertEquals(197.25956, $sut->getTotalRate());
}
public function testAllowedMonths()
{
$date = new DateTime('-8 hours');
$sut = new Day($date, 12340, 197.25956);
$sut->setTotalDuration(999.27);
$sut->setTotalRate(0.123456789);
$this->assertEquals(999, $sut->getTotalDuration());
$this->assertEquals(0.123456789, $sut->getTotalRate());
}
}

View File

@@ -10,6 +10,8 @@
namespace App\Tests\Model\Statistic;
use App\Model\Statistic\Month;
use Exception;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
/**
@@ -42,12 +44,12 @@ class MonthTest extends TestCase
$ex = null;
try {
new Month($month);
} catch (\Exception $e) {
} catch (Exception $e) {
$ex = $e;
}
$this->assertInstanceOf(\InvalidArgumentException::class, $ex);
$this->assertInstanceOf(InvalidArgumentException::class, $ex);
$this->assertEquals(
'Invalid month given, expected 01-12 but given: ' . ((int) $month),
'Invalid month given. Expected 1-12, received "' . ((int) $month) . '".',
$ex->getMessage()
);
}
@@ -59,7 +61,7 @@ class MonthTest extends TestCase
$sut->setTotalDuration(999.27);
$sut->setTotalRate(0.123456789);
$this->assertEquals(999.27, $sut->getTotalDuration());
$this->assertEquals(999, $sut->getTotalDuration());
$this->assertEquals(0.123456789, $sut->getTotalRate());
}
}