improved invoices with new renderer (#306)
* added docx renderer and demo template * added csv renderer and demo template * added xlsx renderer and demo template * added ods renderer and demo template * added user calculator * added invoice documentation
This commit is contained in:
60
tests/Repository/InvoiceDocumentRepositoryTest.php
Normal file
60
tests/Repository/InvoiceDocumentRepositoryTest.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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\Repository;
|
||||
|
||||
use App\Entity\InvoiceDocument;
|
||||
use App\Repository\InvoiceDocumentRepository;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Repository\InvoiceDocumentRepository
|
||||
*/
|
||||
class InvoiceDocumentRepositoryTest extends TestCase
|
||||
{
|
||||
protected static $defaultDirectories = [
|
||||
'templates/invoice/renderer'
|
||||
];
|
||||
|
||||
protected static $defaultDocuments = [
|
||||
'company.docx',
|
||||
'default.html.twig',
|
||||
'export.csv',
|
||||
'freelancer.html.twig',
|
||||
'open-spreadsheet.ods',
|
||||
'spreadsheet.xlsx',
|
||||
'timesheet.html.twig',
|
||||
];
|
||||
|
||||
public function testWithEmptyDirectory()
|
||||
{
|
||||
$sut = new InvoiceDocumentRepository([]);
|
||||
$this->assertEmpty($sut->findAll());
|
||||
$this->assertInternalType('array', $sut->findAll());
|
||||
$this->assertNull($sut->findByName('default'));
|
||||
}
|
||||
|
||||
public function testDefaultTemplatesExists()
|
||||
{
|
||||
$sut = new InvoiceDocumentRepository(self::$defaultDirectories);
|
||||
$all = $sut->findAll();
|
||||
$this->assertEquals(count(self::$defaultDocuments), count($all));
|
||||
|
||||
foreach ($all as $document) {
|
||||
$this->assertTrue(in_array($document->getName(), self::$defaultDocuments));
|
||||
}
|
||||
|
||||
foreach (self::$defaultDocuments as $filename) {
|
||||
$filename = substr($filename, 0, strpos($filename, '.'));
|
||||
$actual = $sut->findByName($filename);
|
||||
$this->assertNotNull($actual);
|
||||
$this->assertInstanceOf(InvoiceDocument::class, $actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user