0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-04-01 04:02:42 +00:00
kevinpapst_kimai2/tests/Repository/InvoiceDocumentRepositoryTest.php
2019-02-19 11:03:11 +01:00

60 lines
1.7 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\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->assertIsArray($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);
}
}
}