0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-01-11 03:48:10 +00:00
kevinpapst_kimai2/tests/Form/Helper/CustomerHelperTest.php
Kevin Papst 3f09a2674b
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
2023-03-02 14:04:06 +01:00

74 lines
2.6 KiB
PHP

<?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));
}
}