0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-05-07 10:30:53 +00:00
kevinpapst_kimai2/tests/Invoice/Hydrator/InvoiceItemDefaultHydratorTest.php
Kevin Papst 29624354a2
Release 2.0.20 (#4028)
* max duration per entry increased from 8 to 10 hours
* fixes #3981 - clickable area in dropdown too small
* fixes #4008 - duplicate activities in project-details report
* headers and summary styling in project-details report
* show billable stats in project-details report
* added new invoice variable for entry.duration_format
2023-05-15 22:30:37 +02:00

103 lines
3 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\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-timesheet', '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.rate_internal',
'entry.rate_internal_nc',
'entry.rate_internal_plain',
'entry.total',
'entry.total_nc',
'entry.total_plain',
'entry.currency',
'entry.duration',
'entry.duration_format',
'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.week',
'entry.weekyear',
'entry.user_id',
'entry.user_name',
'entry.user_alias',
'entry.user_display',
'entry.user_title',
'entry.user_preference.foo',
'entry.user_preference.mad',
'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',
'entry.tags',
];
$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));
}
}