added reporting screen (#1805)
This commit is contained in:
@@ -120,17 +120,19 @@ class DateExtensionsTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getDayNameTestData
|
||||
*/
|
||||
public function testDayName(string $locale, string $date, string $expectedName)
|
||||
public function testDayName(string $locale, string $date, string $expectedName, bool $short)
|
||||
{
|
||||
$sut = $this->getSut($locale, []);
|
||||
self::assertEquals($expectedName, $sut->dayName(new \DateTime($date)));
|
||||
self::assertEquals($expectedName, $sut->dayName(new \DateTime($date), $short));
|
||||
}
|
||||
|
||||
public function getDayNameTestData()
|
||||
{
|
||||
return [
|
||||
['de', '2020-07-09 12:00:00', 'Donnerstag'],
|
||||
['en', '2020-07-09 12:00:00', 'Thursday']
|
||||
['de', '2020-07-09 12:00:00', 'Donnerstag', false],
|
||||
['en', '2020-07-09 12:00:00', 'Thursday', false],
|
||||
['de', '2020-07-09 12:00:00', 'Do.', true],
|
||||
['en', '2020-07-09 12:00:00', 'Thu', true],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class IconExtensionTest extends TestCase
|
||||
'delete', 'repeat', 'edit', 'manual', 'help', 'start', 'start-small', 'stop', 'stop-small', 'filter',
|
||||
'create', 'list', 'print', 'visibility', 'calendar', 'money', 'duration', 'download', 'copy', 'settings',
|
||||
'export', 'pdf', 'csv', 'ods', 'xlsx', 'on', 'off', 'audit', 'home', 'shop', 'about', 'debug', 'profile-stats',
|
||||
'profile', 'warning', 'permissions', 'back', 'tag', 'avatar', 'timesheet-team', 'plugin', 'configuration'
|
||||
'profile', 'warning', 'permissions', 'back', 'tag', 'avatar', 'timesheet-team', 'plugin', 'configuration', 'reporting'
|
||||
];
|
||||
|
||||
// test pre-defined icons
|
||||
|
||||
62
tests/Twig/ReportingExtensionTest.php
Normal file
62
tests/Twig/ReportingExtensionTest.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\Twig;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Twig\ReportingExtension;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
* @covers \App\Twig\ReportingExtension
|
||||
*/
|
||||
class ReportingExtensionTest extends TestCase
|
||||
{
|
||||
protected function getSut(bool $isGranted = false): ReportingExtension
|
||||
{
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
$security = $this->createMock(AuthorizationCheckerInterface::class);
|
||||
$security->method('isGranted')->willReturn($isGranted);
|
||||
|
||||
return new ReportingExtension($dispatcher, $security);
|
||||
}
|
||||
|
||||
public function testGetFunctions()
|
||||
{
|
||||
$sut = $this->getSut();
|
||||
$functions = ['available_reports'];
|
||||
$twigFunctions = $sut->getFunctions();
|
||||
$this->assertCount(\count($functions), $twigFunctions);
|
||||
$i = 0;
|
||||
/** @var TwigFunction $function */
|
||||
foreach ($twigFunctions as $function) {
|
||||
$this->assertInstanceOf(TwigFunction::class, $function);
|
||||
$this->assertEquals($functions[$i++], $function->getName());
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetAvailableReports()
|
||||
{
|
||||
$sut = $this->getSut();
|
||||
$reports = $sut->getAvailableReports(new User());
|
||||
self::assertIsArray($reports);
|
||||
self::assertEmpty($reports);
|
||||
}
|
||||
|
||||
public function testGetAvailableReportsWithPermission()
|
||||
{
|
||||
$sut = $this->getSut(true);
|
||||
$reports = $sut->getAvailableReports(new User());
|
||||
self::assertIsArray($reports);
|
||||
self::assertCount(2, $reports);
|
||||
}
|
||||
}
|
||||
48
tests/Twig/TimesheetExtensionTest.php
Normal file
48
tests/Twig/TimesheetExtensionTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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\Twig;
|
||||
|
||||
use App\Export\ServiceExport;
|
||||
use App\Twig\TimesheetExtension;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
* @covers \App\Twig\TimesheetExtension
|
||||
*/
|
||||
class TimesheetExtensionTest extends TestCase
|
||||
{
|
||||
protected function getSut(): TimesheetExtension
|
||||
{
|
||||
$service = new ServiceExport();
|
||||
|
||||
return new TimesheetExtension($service);
|
||||
}
|
||||
|
||||
public function testGetFunctions()
|
||||
{
|
||||
$sut = $this->getSut();
|
||||
$functions = ['timesheet_exporter'];
|
||||
$twigFunctions = $sut->getFunctions();
|
||||
$this->assertCount(\count($functions), $twigFunctions);
|
||||
$i = 0;
|
||||
/** @var TwigFunction $function */
|
||||
foreach ($twigFunctions as $function) {
|
||||
$this->assertInstanceOf(TwigFunction::class, $function);
|
||||
$this->assertEquals($functions[$i++], $function->getName());
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetExporter()
|
||||
{
|
||||
$sut = $this->getSut();
|
||||
self::assertEquals([], $sut->getTimesheetExporter());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user