users weekly stats as bar-chart in dashboard (#847)
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
<?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\DashboardSection;
|
||||
use App\Model\Widget;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Model\DashboardSection
|
||||
*/
|
||||
class DashboardSectionTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new DashboardSection('test');
|
||||
$this->assertEquals('test', $sut->getTitle());
|
||||
$this->assertEquals(0, $sut->getOrder());
|
||||
$this->assertEquals([], $sut->getWidgets());
|
||||
$this->assertEquals(DashboardSection::TYPE_SIMPLE, $sut->getType());
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new DashboardSection('hello-world');
|
||||
$sut->setType(DashboardSection::TYPE_CHART);
|
||||
$sut->setOrder(13);
|
||||
$sut->addWidget(new Widget('bar', []));
|
||||
|
||||
$this->assertCount(1, $sut->getWidgets());
|
||||
$this->assertEquals(DashboardSection::TYPE_CHART, $sut->getType());
|
||||
$this->assertEquals(13, $sut->getOrder());
|
||||
$this->assertEquals('bar', $sut->getWidgets()[0]->getTitle());
|
||||
}
|
||||
}
|
||||
42
tests/Model/Statistic/DayTest.php
Normal file
42
tests/Model/Statistic/DayTest.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\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());
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user