invoices: choose language and duration format (#1438)

This commit is contained in:
Kevin Papst
2020-02-04 20:27:36 +01:00
committed by GitHub
parent 75dcae6fbe
commit 986d922855
64 changed files with 1559 additions and 541 deletions

View File

@@ -0,0 +1,93 @@
<?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\Invoice\Hydrator;
use App\Invoice\Hydrator\InvoiceItemDefaultHydrator;
use App\Tests\Invoice\Renderer\RendererTestTrait;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Invoice\Hydrator\InvoiceItemDefaultHydrator
*/
class InvoiceItemDefaultHydratorTest extends TestCase
{
use RendererTestTrait;
public function testHydrate()
{
$model = $this->getInvoiceModel();
$sut = new InvoiceItemDefaultHydrator();
$sut->setInvoiceModel($model);
$result = $sut->hydrate($model->getCalculator()->getEntries()[0]);
$metaFields = ['entry.meta.foo-timesheet'];
$this->assertEntryStructure($result, $metaFields);
$result = $sut->hydrate($model->getCalculator()->getEntries()[1]);
$metaFields = ['entry.meta.foo-timesheet2'];
$this->assertEntryStructure($result, $metaFields);
}
protected function assertEntryStructure(array $model, array $metaFields)
{
$keys = [
'entry.row',
'entry.description',
'entry.amount',
'entry.rate',
'entry.rate_nc',
'entry.rate_plain',
'entry.total',
'entry.total_nc',
'entry.total_plain',
'entry.currency',
'entry.duration',
'entry.duration_decimal',
'entry.duration_minutes',
'entry.begin',
'entry.begin_time',
'entry.begin_timestamp',
'entry.end',
'entry.end_time',
'entry.end_timestamp',
'entry.date',
'entry.user_id',
'entry.user_name',
'entry.user_alias',
'entry.user_title',
'entry.activity',
'entry.activity_id',
'entry.activity.meta.foo-activity',
'entry.project',
'entry.project_id',
'entry.project.meta.foo-project',
'entry.customer',
'entry.customer_id',
'entry.customer.meta.foo-customer',
'entry.category',
'entry.type',
];
$keys = array_merge($keys, $metaFields);
foreach ($keys as $key) {
$this->assertArrayHasKey($key, $model);
}
$expectedKeys = array_merge([], $keys);
sort($expectedKeys);
$givenKeys = array_keys($model);
sort($givenKeys);
$this->assertEquals($expectedKeys, $givenKeys);
$this->assertEquals(count($keys), count($givenKeys));
}
}