financial year setting + new users working time per year report (#2547)
This commit is contained in:
@@ -25,8 +25,6 @@ abstract class AbstractWidgetTypeTest extends TestCase
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
self::assertInstanceOf(AbstractWidgetType::class, $sut);
|
||||
self::assertEquals('', $sut->getId());
|
||||
self::assertEquals('', $sut->getTitle());
|
||||
self::assertEquals($this->getDefaultOptions(), $sut->getOptions());
|
||||
self::assertNull($sut->getData());
|
||||
self::assertEquals('bar', $sut->getOption('foo', 'bar'));
|
||||
@@ -51,7 +49,10 @@ abstract class AbstractWidgetTypeTest extends TestCase
|
||||
self::assertEquals(array_merge($this->getDefaultOptions(), ['föööö' => 'trääääää']), $sut->getOptions());
|
||||
|
||||
$sut->setOptions(['blub' => 'blab', 'dataType' => 'money']);
|
||||
self::assertEquals(['blub' => 'blab', 'dataType' => 'money', 'föööö' => 'trääääää'], $sut->getOptions());
|
||||
$options = $sut->getOptions();
|
||||
self::assertEquals('blab', $options['blub']);
|
||||
self::assertEquals('money', $options['dataType']);
|
||||
self::assertEquals('trääääää', $options['föööö']);
|
||||
|
||||
// id
|
||||
$sut->setId('cvbnmyx');
|
||||
|
||||
62
tests/Widget/Type/ActiveUsersYearTest.php
Normal file
62
tests/Widget/Type/ActiveUsersYearTest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Widget\Type;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\ActiveUsersYear;
|
||||
use App\Widget\Type\CounterYear;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\ActiveUsersYear
|
||||
* @covers \App\Widget\Type\CounterYear
|
||||
*/
|
||||
class ActiveUsersYearTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
/**
|
||||
* @return CounterYear
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
|
||||
return new ActiveUsersYear($repository, $configuration);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'int',
|
||||
'icon' => 'user',
|
||||
'color' => 'yellow',
|
||||
];
|
||||
}
|
||||
|
||||
public function testData()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cannot set data on instances of SimpleStatisticChart');
|
||||
|
||||
$sut = $this->createSut();
|
||||
self::assertInstanceOf(SimpleStatisticChart::class, $sut);
|
||||
$sut->setData(10);
|
||||
}
|
||||
|
||||
public function testSettings()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
|
||||
self::assertEquals('widget/widget-counter.html.twig', $sut->getTemplateName());
|
||||
self::assertEquals('activeUsersYear', $sut->getId());
|
||||
}
|
||||
}
|
||||
62
tests/Widget/Type/AmountYearTest.php
Normal file
62
tests/Widget/Type/AmountYearTest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Widget\Type;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\AmountYear;
|
||||
use App\Widget\Type\CounterYear;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\AmountYear
|
||||
* @covers \App\Widget\Type\CounterYear
|
||||
*/
|
||||
class AmountYearTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
/**
|
||||
* @return CounterYear
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
|
||||
return new AmountYear($repository, $configuration);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => 'yellow',
|
||||
];
|
||||
}
|
||||
|
||||
public function testData()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cannot set data on instances of SimpleStatisticChart');
|
||||
|
||||
$sut = $this->createSut();
|
||||
self::assertInstanceOf(SimpleStatisticChart::class, $sut);
|
||||
$sut->setData(10);
|
||||
}
|
||||
|
||||
public function testSettings()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
|
||||
self::assertEquals('widget/widget-counter.html.twig', $sut->getTemplateName());
|
||||
self::assertEquals('amountYear', $sut->getId());
|
||||
}
|
||||
}
|
||||
101
tests/Widget/Type/CounterYearTest.php
Normal file
101
tests/Widget/Type/CounterYearTest.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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\Widget\Type;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Entity\User;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\Counter;
|
||||
use App\Widget\Type\CounterYear;
|
||||
use App\Widget\Type\SimpleWidget;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\CounterYear
|
||||
* @covers \App\Widget\Type\SimpleStatisticChart
|
||||
* @covers \App\Widget\Type\SimpleWidget
|
||||
*/
|
||||
class CounterYearTest extends AbstractSimpleStatisticsWidgetTypeTest
|
||||
{
|
||||
public function createSut(?string $financialYear = null): AbstractWidgetType
|
||||
{
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
|
||||
if (null !== $financialYear) {
|
||||
$configuration->method('getFinancialYearStart')->willReturn($financialYear);
|
||||
}
|
||||
|
||||
$sut = new CounterYear($this->createMock(TimesheetRepository::class), $configuration);
|
||||
$sut->setQuery(TimesheetRepository::STATS_QUERY_ACTIVE);
|
||||
|
||||
return $sut;
|
||||
}
|
||||
|
||||
public function testQueryWithUser()
|
||||
{
|
||||
$user = new User();
|
||||
$user->setAlias('foo');
|
||||
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$repository->expects($this->once())->method('getStatistic')->willReturnCallback(function (string $type, ?DateTime $begin, ?DateTime $end, ?User $user) {
|
||||
self::assertEquals($type, 'active');
|
||||
self::assertNull($begin);
|
||||
self::assertNull($end);
|
||||
self::assertNull($user);
|
||||
});
|
||||
$sut = new Counter($repository);
|
||||
$sut->setQuery(TimesheetRepository::STATS_QUERY_ACTIVE);
|
||||
$sut->setUser($user);
|
||||
$sut->getData([]);
|
||||
|
||||
$user = new User();
|
||||
$user->setAlias('bar');
|
||||
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$repository->expects($this->once())->method('getStatistic')->willReturnCallback(function (string $type, ?DateTime $begin, ?DateTime $end, ?User $user) {
|
||||
self::assertEquals($type, 'active');
|
||||
self::assertNull($begin);
|
||||
self::assertNull($end);
|
||||
self::assertNotNull($user);
|
||||
self::assertEquals('bar', $user->getAlias());
|
||||
});
|
||||
$sut = new Counter($repository);
|
||||
$sut->setQuery(TimesheetRepository::STATS_QUERY_ACTIVE);
|
||||
$sut->setUser($user);
|
||||
$sut->setQueryWithUser(true);
|
||||
$sut->getData([]);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return ['dataType' => 'int'];
|
||||
}
|
||||
|
||||
public function testExtendsSimpleWidget()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
self::assertInstanceOf(SimpleWidget::class, $sut);
|
||||
}
|
||||
|
||||
public function testTemplateName()
|
||||
{
|
||||
/** @var Counter $sut */
|
||||
$sut = $this->createSut();
|
||||
self::assertEquals('widget/widget-counter.html.twig', $sut->getTemplateName());
|
||||
}
|
||||
|
||||
public function testTemplateNameWithFinancialYear()
|
||||
{
|
||||
/** @var Counter $sut */
|
||||
$sut = $this->createSut('2020-01-01');
|
||||
self::assertEquals('widget/widget-counter.html.twig', $sut->getTemplateName());
|
||||
}
|
||||
}
|
||||
62
tests/Widget/Type/DurationYearTest.php
Normal file
62
tests/Widget/Type/DurationYearTest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Widget\Type;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\CounterYear;
|
||||
use App\Widget\Type\DurationYear;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\DurationYear
|
||||
* @covers \App\Widget\Type\CounterYear
|
||||
*/
|
||||
class DurationYearTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
/**
|
||||
* @return CounterYear
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
|
||||
return new DurationYear($repository, $configuration);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'duration',
|
||||
'icon' => 'duration',
|
||||
'color' => 'yellow',
|
||||
];
|
||||
}
|
||||
|
||||
public function testData()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cannot set data on instances of SimpleStatisticChart');
|
||||
|
||||
$sut = $this->createSut();
|
||||
self::assertInstanceOf(SimpleStatisticChart::class, $sut);
|
||||
$sut->setData(10);
|
||||
}
|
||||
|
||||
public function testSettings()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
|
||||
self::assertEquals('widget/widget-counter.html.twig', $sut->getTemplateName());
|
||||
self::assertEquals('durationYear', $sut->getId());
|
||||
}
|
||||
}
|
||||
199
tests/Widget/Type/PaginatedWorkingTimeChartTest.php
Normal file
199
tests/Widget/Type/PaginatedWorkingTimeChartTest.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?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\Widget\Type;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\Project;
|
||||
use App\Entity\User;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\PaginatedWorkingTimeChart;
|
||||
use App\Widget\Type\SimpleWidget;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\PaginatedWorkingTimeChart
|
||||
* @covers \App\Widget\Type\SimpleWidget
|
||||
* @covers \App\Widget\Type\AbstractWidgetType
|
||||
* @covers \App\Repository\TimesheetRepository
|
||||
*/
|
||||
class PaginatedWorkingTimeChartTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @return PaginatedWorkingTimeChart
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
|
||||
$sut = new PaginatedWorkingTimeChart($repository, $configuration);
|
||||
$sut->setUser(new User());
|
||||
|
||||
return $sut;
|
||||
}
|
||||
|
||||
public function testExtendsSimpleWidget()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
self::assertInstanceOf(SimpleWidget::class, $sut);
|
||||
}
|
||||
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
self::assertInstanceOf(AbstractWidgetType::class, $sut);
|
||||
self::assertEquals('PaginatedWorkingTimeChart', $sut->getId());
|
||||
self::assertEquals('stats.yourWorkingHours', $sut->getTitle());
|
||||
//self::assertNull($sut->getOption('begin', 'xxx'));
|
||||
// self::assertNull($sut->getOption('end', 'xxx'));
|
||||
// self::assertEquals('', $sut->getOption('color', 'xxx'));
|
||||
self::assertInstanceOf(User::class, $sut->getOption('user', 'xxx'));
|
||||
// self::assertEquals('bar', $sut->getOption('type', 'xxx'));
|
||||
}
|
||||
|
||||
public function testFluentInterface()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
self::assertInstanceOf(AbstractWidgetType::class, $sut->setOptions([]));
|
||||
self::assertInstanceOf(AbstractWidgetType::class, $sut->setId(''));
|
||||
self::assertInstanceOf(AbstractWidgetType::class, $sut->setTitle(''));
|
||||
self::assertInstanceOf(AbstractWidgetType::class, $sut->setData(''));
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
|
||||
// options
|
||||
$sut->setOption('föööö', 'trääääää');
|
||||
self::assertEquals('trääääää', $sut->getOption('föööö', 'tröööö'));
|
||||
|
||||
// check default values
|
||||
self::assertEquals('xxxxx', $sut->getOption('blub', 'xxxxx'));
|
||||
self::assertEquals('xxxxx', $sut->getOption('dataType', 'xxxxx'));
|
||||
|
||||
$sut->setOptions(['blub' => 'blab', 'dataType' => 'money']);
|
||||
// check option still exists
|
||||
self::assertEquals('trääääää', $sut->getOption('föööö', 'tröööö'));
|
||||
// check options are now existing
|
||||
self::assertEquals('blab', $sut->getOption('blub', 'xxxxx'));
|
||||
self::assertEquals('money', $sut->getOption('dataType', 'xxxxx'));
|
||||
|
||||
// id
|
||||
$sut->setId('cvbnmyx');
|
||||
self::assertEquals('cvbnmyx', $sut->getId());
|
||||
}
|
||||
|
||||
public function testGetOptions()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
|
||||
$options = $sut->getOptions(['type' => 'xxx']);
|
||||
self::assertEquals('bar', $options['type']);
|
||||
}
|
||||
|
||||
public function testGetData()
|
||||
{
|
||||
$activity = $this->createMock(Activity::class);
|
||||
$activity->method('getId')->willReturn(42);
|
||||
|
||||
$project = $this->createMock(Project::class);
|
||||
$project->method('getId')->willReturn(4711);
|
||||
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$repository->expects($this->once())->method('getDailyStats')->willReturnCallback(function ($user, $begin, $end) use ($activity, $project) {
|
||||
return [
|
||||
[
|
||||
'year' => $begin->format('Y'),
|
||||
'month' => $begin->format('n'),
|
||||
'day' => $begin->format('j'),
|
||||
'rate' => 13.75,
|
||||
'duration' => 1234,
|
||||
'billable' => 1234,
|
||||
'details' => [
|
||||
[
|
||||
'activity' => $activity,
|
||||
'project' => $project,
|
||||
'billable' => 1234,
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
});
|
||||
|
||||
$expectedKeys = [
|
||||
'begin', 'end', 'stats', 'thisMonth', 'lastWeekInYear', 'lastWeekInLastYear', 'day', 'week', 'month', 'year', 'financial', 'financialBegin'
|
||||
];
|
||||
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
$configuration->expects($this->once())->method('getFinancialYearStart')->willReturn(null);
|
||||
|
||||
$sut = new PaginatedWorkingTimeChart($repository, $configuration);
|
||||
|
||||
$sut->setUser(new User());
|
||||
$data = $sut->getData([]);
|
||||
|
||||
self::assertCount(\count($expectedKeys), $data);
|
||||
foreach ($expectedKeys as $key) {
|
||||
self::assertArrayHasKey($key, $data);
|
||||
}
|
||||
self::assertNull($data['financialBegin']);
|
||||
}
|
||||
|
||||
public function testGetDataWithFinancialYear()
|
||||
{
|
||||
$activity = $this->createMock(Activity::class);
|
||||
$activity->method('getId')->willReturn(42);
|
||||
|
||||
$project = $this->createMock(Project::class);
|
||||
$project->method('getId')->willReturn(4711);
|
||||
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$repository->expects($this->once())->method('getDailyStats')->willReturnCallback(function ($user, $begin, $end) use ($activity, $project) {
|
||||
return [
|
||||
[
|
||||
'year' => $begin->format('Y'),
|
||||
'month' => $begin->format('n'),
|
||||
'day' => $begin->format('j'),
|
||||
'rate' => 13.75,
|
||||
'duration' => 1234,
|
||||
'billable' => 1234,
|
||||
'details' => [
|
||||
[
|
||||
'activity' => $activity,
|
||||
'project' => $project,
|
||||
'billable' => 1234,
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
});
|
||||
|
||||
$expectedKeys = [
|
||||
'begin', 'end', 'stats', 'thisMonth', 'lastWeekInYear', 'lastWeekInLastYear', 'day', 'week', 'month', 'year', 'financial', 'financialBegin'
|
||||
];
|
||||
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
$configuration->expects($this->once())->method('getFinancialYearStart')->willReturn('2020-01-01');
|
||||
|
||||
$sut = new PaginatedWorkingTimeChart($repository, $configuration);
|
||||
|
||||
$sut->setUser(new User());
|
||||
$data = $sut->getData([]);
|
||||
|
||||
self::assertCount(\count($expectedKeys), $data);
|
||||
foreach ($expectedKeys as $key) {
|
||||
self::assertArrayHasKey($key, $data);
|
||||
}
|
||||
self::assertInstanceOf(\DateTime::class, $data['financialBegin']);
|
||||
}
|
||||
}
|
||||
62
tests/Widget/Type/UserAmountYearTest.php
Normal file
62
tests/Widget/Type/UserAmountYearTest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Widget\Type;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\CounterYear;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\Type\UserAmountYear;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\UserAmountYear
|
||||
* @covers \App\Widget\Type\CounterYear
|
||||
*/
|
||||
class UserAmountYearTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
/**
|
||||
* @return CounterYear
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
|
||||
return new UserAmountYear($repository, $configuration);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => 'yellow',
|
||||
];
|
||||
}
|
||||
|
||||
public function testData()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cannot set data on instances of SimpleStatisticChart');
|
||||
|
||||
$sut = $this->createSut();
|
||||
self::assertInstanceOf(SimpleStatisticChart::class, $sut);
|
||||
$sut->setData(10);
|
||||
}
|
||||
|
||||
public function testSettings()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
|
||||
self::assertEquals('widget/widget-counter.html.twig', $sut->getTemplateName());
|
||||
self::assertEquals('userAmountYear', $sut->getId());
|
||||
}
|
||||
}
|
||||
62
tests/Widget/Type/UserDurationYearTest.php
Normal file
62
tests/Widget/Type/UserDurationYearTest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Widget\Type;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\CounterYear;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\Type\UserDurationYear;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\UserDurationYear
|
||||
* @covers \App\Widget\Type\CounterYear
|
||||
*/
|
||||
class UserDurationYearTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
/**
|
||||
* @return CounterYear
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
|
||||
return new UserDurationYear($repository, $configuration);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'duration',
|
||||
'icon' => 'duration',
|
||||
'color' => 'yellow',
|
||||
];
|
||||
}
|
||||
|
||||
public function testData()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cannot set data on instances of SimpleStatisticChart');
|
||||
|
||||
$sut = $this->createSut();
|
||||
self::assertInstanceOf(SimpleStatisticChart::class, $sut);
|
||||
$sut->setData(10);
|
||||
}
|
||||
|
||||
public function testSettings()
|
||||
{
|
||||
$sut = $this->createSut();
|
||||
|
||||
self::assertEquals('widget/widget-counter.html.twig', $sut->getTemplateName());
|
||||
self::assertEquals('userDurationYear', $sut->getId());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user