invoices: choose language and duration format (#1438)
This commit is contained in:
@@ -57,7 +57,7 @@ class CsvRendererTest extends TestCase
|
||||
|
||||
$file = $response->getFile();
|
||||
$this->assertEquals('text/csv', $response->headers->get('Content-Type'));
|
||||
$this->assertEquals('attachment; filename=export.csv', $response->headers->get('Content-Disposition'));
|
||||
$this->assertEquals('attachment; filename=200204-customer_with_special_name.csv', $response->headers->get('Content-Disposition'));
|
||||
|
||||
$this->assertTrue(file_exists($file->getRealPath()));
|
||||
$content = file_get_contents($file->getRealPath());
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
namespace App\Tests\Invoice\Renderer;
|
||||
|
||||
use App\Entity\InvoiceDocument;
|
||||
use App\Invoice\InvoiceItem;
|
||||
use App\Invoice\InvoiceItemHydrator;
|
||||
use App\Invoice\InvoiceModel;
|
||||
use App\Invoice\InvoiceModelHydrator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
@@ -29,6 +32,26 @@ class DebugRendererTest extends TestCase
|
||||
*/
|
||||
public function testRender(InvoiceModel $model, $expectedRate, $expectedRows, $expectedDescriptions, $expectedUser1, $expectedUser2, $expectedUser3, $hasProject, $metaFields = [])
|
||||
{
|
||||
$itemHydrator = new class() implements InvoiceItemHydrator {
|
||||
public function setInvoiceModel(InvoiceModel $model)
|
||||
{
|
||||
}
|
||||
|
||||
public function hydrate(InvoiceItem $item): array
|
||||
{
|
||||
return ['testFromItemHydrator' => 'foo'];
|
||||
}
|
||||
};
|
||||
$model->addItemHydrator($itemHydrator);
|
||||
|
||||
$modelHydrator = new class() implements InvoiceModelHydrator {
|
||||
public function hydrate(InvoiceModel $model): array
|
||||
{
|
||||
return ['testFromModelHydrator' => 'foo'];
|
||||
}
|
||||
};
|
||||
$model->addModelHydrator($modelHydrator);
|
||||
|
||||
$document = new InvoiceDocument(new \SplFileInfo(__DIR__ . '/DebugRenderer.php'));
|
||||
$sut = new DebugRenderer();
|
||||
/** @var Response $response */
|
||||
@@ -119,6 +142,7 @@ class DebugRendererTest extends TestCase
|
||||
'user.title',
|
||||
'user.meta.hello',
|
||||
'user.meta.kitty',
|
||||
'testFromModelHydrator'
|
||||
];
|
||||
|
||||
if ($hasProject) {
|
||||
@@ -191,6 +215,7 @@ class DebugRendererTest extends TestCase
|
||||
'entry.customer.meta.foo-customer',
|
||||
'entry.category',
|
||||
'entry.type',
|
||||
'testFromItemHydrator'
|
||||
];
|
||||
|
||||
$keys = array_merge($keys, $metaFields);
|
||||
|
||||
@@ -47,7 +47,7 @@ class DocxRendererTest extends TestCase
|
||||
|
||||
$file = $response->getFile();
|
||||
$this->assertEquals('application/vnd.openxmlformats-officedocument.wordprocessingml.document', $response->headers->get('Content-Type'));
|
||||
$this->assertEquals('attachment; filename=company.docx', $response->headers->get('Content-Disposition'));
|
||||
$this->assertEquals('attachment; filename=200204-customer_with_special_name.docx', $response->headers->get('Content-Disposition'));
|
||||
|
||||
$this->assertTrue(file_exists($file->getRealPath()));
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class OdsRendererTest extends TestCase
|
||||
|
||||
$file = $response->getFile();
|
||||
$this->assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type'));
|
||||
$this->assertEquals('attachment; filename=open-spreadsheet.ods', $response->headers->get('Content-Disposition'));
|
||||
$this->assertEquals('attachment; filename=200204-customer_with_special_name.ods', $response->headers->get('Content-Disposition'));
|
||||
|
||||
$this->assertTrue(file_exists($file->getRealPath()));
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ trait RendererTestTrait
|
||||
$user->addPreference((new UserPreference())->setName('hello')->setValue('world'));
|
||||
|
||||
$customer = new Customer();
|
||||
$customer->setName('customer,with/special#name');
|
||||
$customer->setCurrency('EUR');
|
||||
$customer->setMetaField((new CustomerMeta())->setName('foo-customer')->setValue('bar-customer')->setIsVisible(true));
|
||||
|
||||
@@ -232,6 +233,7 @@ trait RendererTestTrait
|
||||
$user->addPreference((new UserPreference())->setName('hello')->setValue('world'));
|
||||
|
||||
$customer = new Customer();
|
||||
$customer->setName('customer,with/special#name');
|
||||
$customer->setCurrency('USD');
|
||||
$customer->setMetaField((new CustomerMeta())->setName('foo-customer')->setValue('bar-customer')->setIsVisible(true));
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ class TwigRendererTest extends KernelTestCase
|
||||
|
||||
$content = $response->getContent();
|
||||
|
||||
$this->assertStringContainsString('<title>200204-customer_with_special_name</title>', $content);
|
||||
$this->assertStringContainsString('<h2 class="page-header">
|
||||
<span contenteditable="true">a very *long* test invoice / template title with [special] character</span>
|
||||
</h2>', $content);
|
||||
|
||||
@@ -58,7 +58,7 @@ class XlsxRendererTest extends TestCase
|
||||
|
||||
$file = $response->getFile();
|
||||
$this->assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type'));
|
||||
$this->assertEquals('attachment; filename=spreadsheet.xlsx', $response->headers->get('Content-Disposition'));
|
||||
$this->assertEquals('attachment; filename=200204-customer_with_special_name.xlsx', $response->headers->get('Content-Disposition'));
|
||||
|
||||
$this->assertTrue(file_exists($file->getRealPath()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user