refactored invoice and export screens (#1046)

This commit is contained in:
Kevin Papst
2019-08-22 18:56:21 +02:00
committed by GitHub
parent 405ea0076b
commit 46e5650882
55 changed files with 930 additions and 906 deletions

View File

@@ -20,7 +20,6 @@ use App\Entity\User;
use App\Export\RendererInterface;
use App\Repository\Query\TimesheetQuery;
use App\Twig\DateExtensions;
use App\Twig\Extensions;
use App\Utils\LocaleSettings;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpFoundation\Request;
@@ -52,9 +51,8 @@ abstract class AbstractRendererTest extends KernelTestCase
$translator = $this->getMockBuilder(TranslatorInterface::class)->getMock();
$dateExtension = new DateExtensions($localeSettings);
$extensions = new Extensions($localeSettings);
return new $classname($translator, $dateExtension, $extensions);
return new $classname($translator, $dateExtension);
}
/**

View File

@@ -32,7 +32,7 @@ class CsvRendererTest extends AbstractRendererTest
public function getTestModel()
{
return [
['01:50 h', '€2,437.12', '1,947.99', 7, 5, 1, 2, 2]
['400', '2437.12', ' EUR 1,947.99 ', 7, 5, 1, 2, 2]
];
}
@@ -76,26 +76,27 @@ class CsvRendererTest extends AbstractRendererTest
}
$expected = [
0 => '2019.06.16 12:00',
1 => '2019.06.16 12:06',
2 => 'kevin',
3 => 'Customer Name',
4 => 'project name',
5 => 'activity description',
6 => '',
7 => '',
8 => 'foo,bar',
9 => 'meta-bar',
10 => 'meta-bar2',
11 => '€0.00',
12 => '€84.00',
13 => '00:06 h',
14 => '€0.00',
0 => '2019-06-16',
1 => '12:00',
2 => '12:06',
3 => '400',
4 => '0',
5 => 'kevin',
6 => 'Customer Name',
7 => 'project name',
8 => 'activity description',
9 => '',
10 => '',
11 => 'foo,bar',
12 => '',
13 => ' EUR 84.00 ',
14 => 'meta-bar',
15 => 'meta-bar2',
];
self::assertEquals(7, count($all));
self::assertEquals(count($expected), count($all[0]));
self::assertEquals('foo', $all[4][8]);
self::assertEquals('foo', $all[4][11]);
self::assertEquals($expected, $all[5]);
}

View File

@@ -1,52 +0,0 @@
<?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\Export\Renderer;
use App\Export\Renderer\OdsRenderer;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
/**
* @covers \App\Export\Renderer\OdsRenderer
* @covers \App\Export\Renderer\AbstractSpreadsheetRenderer
* @covers \App\Export\Renderer\RendererTrait
* @group integration
*/
class OdsRendererTest extends AbstractRendererTest
{
public function testConfiguration()
{
$sut = $this->getAbstractRenderer(OdsRenderer::class);
$this->assertEquals('ods', $sut->getId());
$this->assertEquals('ods', $sut->getTitle());
$this->assertEquals('ods', $sut->getIcon());
}
public function testRender()
{
$sut = $this->getAbstractRenderer(OdsRenderer::class);
/** @var BinaryFileResponse $response */
$response = $this->render($sut);
$file = $response->getFile();
$this->assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type'));
$this->assertEquals('attachment; filename=kimai-export.ods', $response->headers->get('Content-Disposition'));
$this->assertTrue(file_exists($file->getRealPath()));
ob_start();
$response->sendContent();
$content2 = ob_get_clean();
$this->assertNotEmpty($content2);
$this->assertFalse(file_exists($file->getRealPath()));
}
}