Release 2.0.4 (#3883)
* fix column data truncated * calculate internal rate from user * show internal rate in timesheet listing * Fixed: responsivenss and size of report start page icons * fix: name display in dropdowns (and added tests) * translate reload button * fix invoice date might be in the past * fail safe customer name handling * translate invoice_date and invoice_date help * prevent URLs like start=null * prevent to reload select twice
This commit is contained in:
62
tests/Form/Helper/ActivityHelperTest.php
Normal file
62
tests/Form/Helper/ActivityHelperTest.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\Form\Helper;
|
||||
|
||||
use App\Entity\Activity;
|
||||
use App\Form\Helper\ActivityHelper;
|
||||
use App\Tests\Mocks\SystemConfigurationFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Form\Helper\ActivityHelper
|
||||
*/
|
||||
class ActivityHelperTest extends TestCase
|
||||
{
|
||||
private function createSut(string $format): ActivityHelper
|
||||
{
|
||||
$config = SystemConfigurationFactory::createStub(['activity.choice_pattern' => $format]);
|
||||
$helper = new ActivityHelper($config);
|
||||
|
||||
return $helper;
|
||||
}
|
||||
|
||||
public function testInvalidPattern(): void
|
||||
{
|
||||
$helper = $this->createSut('sdfsdf');
|
||||
self::assertEquals(ActivityHelper::PATTERN_NAME, $helper->getChoicePattern());
|
||||
}
|
||||
|
||||
public function testGetChoicePattern(): void
|
||||
{
|
||||
$helper = $this->createSut(
|
||||
ActivityHelper::PATTERN_NAME . ActivityHelper::PATTERN_SPACER .
|
||||
ActivityHelper::PATTERN_COMMENT
|
||||
);
|
||||
|
||||
self::assertEquals(
|
||||
ActivityHelper::PATTERN_NAME . ActivityHelper::SPACER .
|
||||
ActivityHelper::PATTERN_COMMENT,
|
||||
$helper->getChoicePattern()
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetChoiceLabel(): void
|
||||
{
|
||||
$helper = $this->createSut(ActivityHelper::PATTERN_NAME . ActivityHelper::PATTERN_SPACER . ActivityHelper::PATTERN_COMMENT);
|
||||
|
||||
$activity = new Activity();
|
||||
$activity->setName(' - --- - -FOO BAR- --- - - - ');
|
||||
self::assertEquals('--- - -FOO BAR- ---', $helper->getChoiceLabel($activity));
|
||||
|
||||
$activity->setName('FOO BAR');
|
||||
$activity->setComment('Lorem Ipsum');
|
||||
self::assertEquals('FOO BAR - Lorem Ipsum', $helper->getChoiceLabel($activity));
|
||||
}
|
||||
}
|
||||
74
tests/Form/Helper/CustomerHelperTest.php
Normal file
74
tests/Form/Helper/CustomerHelperTest.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?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\Form\Helper;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Form\Helper\CustomerHelper;
|
||||
use App\Tests\Mocks\SystemConfigurationFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Form\Helper\CustomerHelper
|
||||
*/
|
||||
class CustomerHelperTest extends TestCase
|
||||
{
|
||||
private function createSut(string $format): CustomerHelper
|
||||
{
|
||||
$config = SystemConfigurationFactory::createStub(['customer.choice_pattern' => $format]);
|
||||
$helper = new CustomerHelper($config);
|
||||
|
||||
return $helper;
|
||||
}
|
||||
|
||||
public function testInvalidPattern(): void
|
||||
{
|
||||
$helper = $this->createSut('sdfsdf');
|
||||
self::assertEquals(CustomerHelper::PATTERN_NAME, $helper->getChoicePattern());
|
||||
}
|
||||
|
||||
public function testGetChoicePattern(): void
|
||||
{
|
||||
$helper = $this->createSut(
|
||||
CustomerHelper::PATTERN_NAME . CustomerHelper::PATTERN_SPACER .
|
||||
CustomerHelper::PATTERN_COMMENT . CustomerHelper::PATTERN_SPACER .
|
||||
CustomerHelper::PATTERN_COMPANY . CustomerHelper::PATTERN_SPACER .
|
||||
CustomerHelper::PATTERN_NUMBER
|
||||
);
|
||||
|
||||
self::assertEquals(
|
||||
CustomerHelper::PATTERN_NAME . CustomerHelper::SPACER .
|
||||
CustomerHelper::PATTERN_COMMENT . CustomerHelper::SPACER .
|
||||
CustomerHelper::PATTERN_COMPANY . CustomerHelper::SPACER .
|
||||
CustomerHelper::PATTERN_NUMBER,
|
||||
$helper->getChoicePattern()
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetChoiceLabel(): void
|
||||
{
|
||||
$helper = $this->createSut(
|
||||
CustomerHelper::PATTERN_NAME . CustomerHelper::PATTERN_SPACER .
|
||||
CustomerHelper::PATTERN_COMMENT . CustomerHelper::PATTERN_SPACER .
|
||||
CustomerHelper::PATTERN_COMPANY . CustomerHelper::PATTERN_SPACER .
|
||||
CustomerHelper::PATTERN_NUMBER
|
||||
);
|
||||
|
||||
$customer = new Customer(' - --- - -FOO BAR- --- - - - ');
|
||||
self::assertEquals('--- - -FOO BAR- ---', $helper->getChoiceLabel($customer));
|
||||
|
||||
$customer = new Customer('FOO BAR');
|
||||
$customer->setComment('Lorem Ipsum');
|
||||
self::assertEquals('FOO BAR - Lorem Ipsum', $helper->getChoiceLabel($customer));
|
||||
$customer->setCompany('Acme University');
|
||||
self::assertEquals('FOO BAR - Lorem Ipsum - Acme University', $helper->getChoiceLabel($customer));
|
||||
$customer->setNumber('2023-0815');
|
||||
self::assertEquals('FOO BAR - Lorem Ipsum - Acme University - 2023-0815', $helper->getChoiceLabel($customer));
|
||||
}
|
||||
}
|
||||
109
tests/Form/Helper/ProjectHelperTest.php
Normal file
109
tests/Form/Helper/ProjectHelperTest.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?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\Form\Helper;
|
||||
|
||||
use App\Configuration\LocaleService;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Project;
|
||||
use App\Form\Helper\ProjectHelper;
|
||||
use App\Tests\Mocks\SystemConfigurationFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Form\Helper\ProjectHelper
|
||||
*/
|
||||
class ProjectHelperTest extends TestCase
|
||||
{
|
||||
private function createSut(string $format): ProjectHelper
|
||||
{
|
||||
$config = SystemConfigurationFactory::createStub(['project.choice_pattern' => $format]);
|
||||
|
||||
$localeService = new LocaleService(['en_US' => ['date' => 'dd.MM.y']]);
|
||||
$translator = $this->createMock(TranslatorInterface::class);
|
||||
$translator->method('trans')->willReturn('dating');
|
||||
$helper = new ProjectHelper($config, $localeService, $translator);
|
||||
$helper->setLocale('en_US');
|
||||
|
||||
return $helper;
|
||||
}
|
||||
|
||||
public function testInvalidPattern(): void
|
||||
{
|
||||
$helper = $this->createSut('sdfsdf');
|
||||
self::assertEquals(ProjectHelper::PATTERN_NAME, $helper->getChoicePattern());
|
||||
}
|
||||
|
||||
public function testGetChoicePattern(): void
|
||||
{
|
||||
$helper = $this->createSut(
|
||||
ProjectHelper::PATTERN_NAME . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_COMMENT . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_CUSTOMER . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_ORDERNUMBER . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_START . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_END . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_DATERANGE
|
||||
);
|
||||
|
||||
self::assertEquals(
|
||||
ProjectHelper::PATTERN_NAME . ProjectHelper::SPACER .
|
||||
ProjectHelper::PATTERN_COMMENT . ProjectHelper::SPACER .
|
||||
ProjectHelper::PATTERN_CUSTOMER . ProjectHelper::SPACER .
|
||||
ProjectHelper::PATTERN_ORDERNUMBER . ProjectHelper::SPACER .
|
||||
ProjectHelper::PATTERN_START . ProjectHelper::SPACER .
|
||||
ProjectHelper::PATTERN_END . ProjectHelper::SPACER .
|
||||
ProjectHelper::PATTERN_START . '-' . ProjectHelper::PATTERN_END,
|
||||
$helper->getChoicePattern()
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetChoiceLabel(): void
|
||||
{
|
||||
$helper = $this->createSut(
|
||||
ProjectHelper::PATTERN_NAME . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_COMMENT . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_CUSTOMER . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_ORDERNUMBER
|
||||
);
|
||||
|
||||
$project = new Project();
|
||||
$project->setName(' - --- - -FOO BAR- --- - - - ');
|
||||
$customer = new Customer(' - --- - - Acme company- --- - - - ');
|
||||
$project->setCustomer($customer);
|
||||
self::assertEquals('--- - -FOO BAR- --- - - - - - - --- - - Acme company- ---', $helper->getChoiceLabel($project));
|
||||
|
||||
$project = new Project();
|
||||
$project->setName('FOO BAR');
|
||||
$customer = new Customer('Acme company');
|
||||
$project->setCustomer($customer);
|
||||
$project->setComment('Lorem Ipsum');
|
||||
$project->setOrderNumber('F76/123');
|
||||
self::assertEquals('FOO BAR - Lorem Ipsum - Acme company - F76/123', $helper->getChoiceLabel($project));
|
||||
}
|
||||
|
||||
public function testGetChoiceLabelWithDates(): void
|
||||
{
|
||||
$helper = $this->createSut(
|
||||
ProjectHelper::PATTERN_NAME . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_START . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_END . ProjectHelper::PATTERN_SPACER .
|
||||
ProjectHelper::PATTERN_DATERANGE
|
||||
);
|
||||
|
||||
$project = new Project();
|
||||
$project->setName('FOO BAR');
|
||||
self::assertEquals('FOO BAR - - - -', $helper->getChoiceLabel($project));
|
||||
$project->setStart(new \DateTime('2018-12-27 18:45:12'));
|
||||
self::assertEquals('FOO BAR - dating: 27.12.2018 - - dating: 27.12.2018-', $helper->getChoiceLabel($project));
|
||||
$project->setEnd(new \DateTime('2019-02-14 01:23:45'));
|
||||
self::assertEquals('FOO BAR - dating: 27.12.2018 - dating: 14.02.2019 - dating: 27.12.2018-dating: 14.02.2019', $helper->getChoiceLabel($project));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user