added explicit classes for widgets (#3170)
This commit is contained in:
@@ -58,10 +58,6 @@ abstract class AbstractWidgetTypeTest extends TestCase
|
||||
self::assertEquals('blab', $options['blub']);
|
||||
self::assertEquals('money', $options['dataType']);
|
||||
self::assertEquals('trääääää', $options['föööö']);
|
||||
|
||||
// id
|
||||
$sut->setId('cvbnmyx');
|
||||
self::assertEquals('cvbnmyx', $sut->getId());
|
||||
}
|
||||
|
||||
public function testData()
|
||||
|
||||
68
tests/Widget/Type/AmountMonthTest.php
Normal file
68
tests/Widget/Type/AmountMonthTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractAmountPeriod;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\AmountMonth;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\WidgetInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\AmountMonth
|
||||
* @covers \App\Widget\Type\AbstractAmountPeriod
|
||||
*/
|
||||
class AmountMonthTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
protected function assertDefaultData(AbstractWidgetType $sut)
|
||||
{
|
||||
self::assertEquals(0.0, $sut->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractAmountPeriod
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
return new AmountMonth($repository, $dispatcher);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => WidgetInterface::COLOR_MONTH,
|
||||
];
|
||||
}
|
||||
|
||||
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('amountMonth', $sut->getId());
|
||||
}
|
||||
}
|
||||
68
tests/Widget/Type/AmountTodayTest.php
Normal file
68
tests/Widget/Type/AmountTodayTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractAmountPeriod;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\AmountToday;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\WidgetInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\AmountToday
|
||||
* @covers \App\Widget\Type\AbstractAmountPeriod
|
||||
*/
|
||||
class AmountTodayTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
protected function assertDefaultData(AbstractWidgetType $sut)
|
||||
{
|
||||
self::assertEquals(0.0, $sut->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractAmountPeriod
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
return new AmountToday($repository, $dispatcher);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => WidgetInterface::COLOR_TODAY,
|
||||
];
|
||||
}
|
||||
|
||||
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('amountToday', $sut->getId());
|
||||
}
|
||||
}
|
||||
68
tests/Widget/Type/AmountTotalTest.php
Normal file
68
tests/Widget/Type/AmountTotalTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractAmountPeriod;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\AmountTotal;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\WidgetInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\AmountTotal
|
||||
* @covers \App\Widget\Type\AbstractAmountPeriod
|
||||
*/
|
||||
class AmountTotalTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
protected function assertDefaultData(AbstractWidgetType $sut)
|
||||
{
|
||||
self::assertEquals(0.0, $sut->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractAmountPeriod
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
return new AmountTotal($repository, $dispatcher);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => WidgetInterface::COLOR_TOTAL,
|
||||
];
|
||||
}
|
||||
|
||||
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('amountTotal', $sut->getId());
|
||||
}
|
||||
}
|
||||
68
tests/Widget/Type/AmountWeekTest.php
Normal file
68
tests/Widget/Type/AmountWeekTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractAmountPeriod;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\AmountWeek;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\WidgetInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\AmountWeek
|
||||
* @covers \App\Widget\Type\AbstractAmountPeriod
|
||||
*/
|
||||
class AmountWeekTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
protected function assertDefaultData(AbstractWidgetType $sut)
|
||||
{
|
||||
self::assertEquals(0.0, $sut->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractAmountPeriod
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
return new AmountWeek($repository, $dispatcher);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => WidgetInterface::COLOR_WEEK,
|
||||
];
|
||||
}
|
||||
|
||||
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('amountWeek', $sut->getId());
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\AmountYear;
|
||||
use App\Widget\Type\CounterYear;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\WidgetInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\AmountYear
|
||||
@@ -22,6 +24,11 @@ use App\Widget\Type\SimpleStatisticChart;
|
||||
*/
|
||||
class AmountYearTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
protected function assertDefaultData(AbstractWidgetType $sut)
|
||||
{
|
||||
self::assertEquals(0.0, $sut->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CounterYear
|
||||
*/
|
||||
@@ -29,8 +36,9 @@ class AmountYearTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
return new AmountYear($repository, $configuration);
|
||||
return new AmountYear($repository, $configuration, $dispatcher);
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
@@ -38,7 +46,7 @@ class AmountYearTest extends AbstractWidgetTypeTest
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => 'yellow',
|
||||
'color' => WidgetInterface::COLOR_YEAR,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
72
tests/Widget/Type/UserAmountMonthTest.php
Normal file
72
tests/Widget/Type/UserAmountMonthTest.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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\Entity\User;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractUserAmountPeriod;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\Type\UserAmountMonth;
|
||||
use App\Widget\WidgetInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\UserAmountMonth
|
||||
* @covers \App\Widget\Type\AbstractUserAmountPeriod
|
||||
*/
|
||||
class UserAmountMonthTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
protected function assertDefaultData(AbstractWidgetType $sut)
|
||||
{
|
||||
self::assertEquals(0.0, $sut->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractUserAmountPeriod
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
$widget = new UserAmountMonth($repository, $dispatcher);
|
||||
$widget->setUser(new User());
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => WidgetInterface::COLOR_MONTH,
|
||||
];
|
||||
}
|
||||
|
||||
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('userAmountMonth', $sut->getId());
|
||||
}
|
||||
}
|
||||
72
tests/Widget/Type/UserAmountTodayTest.php
Normal file
72
tests/Widget/Type/UserAmountTodayTest.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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\Entity\User;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractUserAmountPeriod;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\Type\UserAmountToday;
|
||||
use App\Widget\WidgetInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\UserAmountToday
|
||||
* @covers \App\Widget\Type\AbstractUserAmountPeriod
|
||||
*/
|
||||
class UserAmountTodayTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
protected function assertDefaultData(AbstractWidgetType $sut)
|
||||
{
|
||||
self::assertEquals(0.0, $sut->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractUserAmountPeriod
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
$widget = new UserAmountToday($repository, $dispatcher);
|
||||
$widget->setUser(new User());
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => WidgetInterface::COLOR_TODAY,
|
||||
];
|
||||
}
|
||||
|
||||
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('userAmountToday', $sut->getId());
|
||||
}
|
||||
}
|
||||
72
tests/Widget/Type/UserAmountTotalTest.php
Normal file
72
tests/Widget/Type/UserAmountTotalTest.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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\Entity\User;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractUserAmountPeriod;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\Type\UserAmountTotal;
|
||||
use App\Widget\WidgetInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\UserAmountTotal
|
||||
* @covers \App\Widget\Type\AbstractUserAmountPeriod
|
||||
*/
|
||||
class UserAmountTotalTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
protected function assertDefaultData(AbstractWidgetType $sut)
|
||||
{
|
||||
self::assertEquals(0.0, $sut->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractUserAmountPeriod
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
$widget = new UserAmountTotal($repository, $dispatcher);
|
||||
$widget->setUser(new User());
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => WidgetInterface::COLOR_TOTAL,
|
||||
];
|
||||
}
|
||||
|
||||
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('userAmountTotal', $sut->getId());
|
||||
}
|
||||
}
|
||||
72
tests/Widget/Type/UserAmountWeekTest.php
Normal file
72
tests/Widget/Type/UserAmountWeekTest.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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\Entity\User;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Widget\Type\AbstractUserAmountPeriod;
|
||||
use App\Widget\Type\AbstractWidgetType;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\Type\UserAmountWeek;
|
||||
use App\Widget\WidgetInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\UserAmountWeek
|
||||
* @covers \App\Widget\Type\AbstractUserAmountPeriod
|
||||
*/
|
||||
class UserAmountWeekTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
protected function assertDefaultData(AbstractWidgetType $sut)
|
||||
{
|
||||
self::assertEquals(0.0, $sut->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractUserAmountPeriod
|
||||
*/
|
||||
public function createSut(): AbstractWidgetType
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
$widget = new UserAmountWeek($repository, $dispatcher);
|
||||
$widget->setUser(new User());
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
{
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => WidgetInterface::COLOR_WEEK,
|
||||
];
|
||||
}
|
||||
|
||||
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('userAmountWeek', $sut->getId());
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,14 @@
|
||||
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\CounterYear;
|
||||
use App\Widget\Type\SimpleStatisticChart;
|
||||
use App\Widget\Type\UserAmountYear;
|
||||
use App\Widget\WidgetInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Widget\Type\UserAmountYear
|
||||
@@ -22,6 +25,11 @@ use App\Widget\Type\UserAmountYear;
|
||||
*/
|
||||
class UserAmountYearTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
protected function assertDefaultData(AbstractWidgetType $sut)
|
||||
{
|
||||
self::assertEquals(0.0, $sut->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CounterYear
|
||||
*/
|
||||
@@ -29,8 +37,12 @@ class UserAmountYearTest extends AbstractWidgetTypeTest
|
||||
{
|
||||
$repository = $this->createMock(TimesheetRepository::class);
|
||||
$configuration = $this->createMock(SystemConfiguration::class);
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
|
||||
return new UserAmountYear($repository, $configuration);
|
||||
$widget = new UserAmountYear($repository, $configuration, $dispatcher);
|
||||
$widget->setUser(new User());
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
public function getDefaultOptions(): array
|
||||
@@ -38,7 +50,7 @@ class UserAmountYearTest extends AbstractWidgetTypeTest
|
||||
return [
|
||||
'dataType' => 'money',
|
||||
'icon' => 'money',
|
||||
'color' => 'yellow',
|
||||
'color' => WidgetInterface::COLOR_YEAR,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user