invoices: choose language and duration format (#1438)
This commit is contained in:
@@ -33,7 +33,7 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
|
||||
$result = $client->getCrawler()->filter('section.content div.box.box-primary');
|
||||
$this->assertEquals(count($expectedForms), count($result));
|
||||
|
||||
$result = $client->getCrawler()->filter('section.content div.box.box-primary form');
|
||||
$result = $client->getCrawler()->filter('section.content form div.box.box-primary');
|
||||
$this->assertEquals(count($expectedForms), count($result));
|
||||
|
||||
foreach ($expectedForms as $formConfig) {
|
||||
|
||||
30
tests/Entity/InvoiceDocumentTest.php
Normal file
30
tests/Entity/InvoiceDocumentTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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\Entity;
|
||||
|
||||
use App\Entity\InvoiceDocument;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\InvoiceDocument
|
||||
*/
|
||||
class InvoiceDocumentTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$dir = realpath(__DIR__ . '/../../templates/invoice/renderer');
|
||||
$sut = new InvoiceDocument(new \SplFileInfo($dir . '/default.html.twig'));
|
||||
|
||||
self::assertEquals('twig', $sut->getFileExtension());
|
||||
self::assertStringContainsString('templates/invoice/renderer/default.html.twig', $sut->getFilename());
|
||||
self::assertEquals('default', $sut->getId());
|
||||
self::assertEquals('default.html.twig', $sut->getName());
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,8 @@ class InvoiceTemplateTest extends TestCase
|
||||
self::assertEquals('default', $sut->getNumberGenerator());
|
||||
self::assertEquals('default', $sut->getRenderer());
|
||||
self::assertEquals(30, $sut->getDueDays());
|
||||
self::assertFalse($sut->isDecimalDuration());
|
||||
self::assertNull($sut->getLanguage());
|
||||
}
|
||||
|
||||
public function testSetNullForOptionalValues()
|
||||
@@ -46,6 +48,7 @@ class InvoiceTemplateTest extends TestCase
|
||||
self::assertInstanceOf(InvoiceTemplate::class, $sut->setContact(null));
|
||||
self::assertInstanceOf(InvoiceTemplate::class, $sut->setAddress(null));
|
||||
self::assertInstanceOf(InvoiceTemplate::class, $sut->setPaymentTerms(null));
|
||||
self::assertInstanceOf(InvoiceTemplate::class, $sut->setLanguage(null));
|
||||
}
|
||||
|
||||
public function testSetterAndGetter()
|
||||
@@ -66,6 +69,12 @@ class InvoiceTemplateTest extends TestCase
|
||||
|
||||
self::assertInstanceOf(InvoiceTemplate::class, $sut->setVatId('1234567890'));
|
||||
self::assertEquals('1234567890', $sut->getVatId());
|
||||
|
||||
self::assertInstanceOf(InvoiceTemplate::class, $sut->setDecimalDuration(true));
|
||||
self::assertTrue($sut->isDecimalDuration());
|
||||
|
||||
self::assertInstanceOf(InvoiceTemplate::class, $sut->setLanguage('de'));
|
||||
self::assertEquals('de', $sut->getLanguage());
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
|
||||
93
tests/Invoice/Hydrator/InvoiceItemDefaultHydratorTest.php
Normal file
93
tests/Invoice/Hydrator/InvoiceItemDefaultHydratorTest.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?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-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.total',
|
||||
'entry.total_nc',
|
||||
'entry.total_plain',
|
||||
'entry.currency',
|
||||
'entry.duration',
|
||||
'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.user_id',
|
||||
'entry.user_name',
|
||||
'entry.user_alias',
|
||||
'entry.user_title',
|
||||
'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',
|
||||
];
|
||||
|
||||
$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));
|
||||
}
|
||||
}
|
||||
58
tests/Invoice/Hydrator/InvoiceModelActivityHydratorTest.php
Normal file
58
tests/Invoice/Hydrator/InvoiceModelActivityHydratorTest.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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\InvoiceModelActivityHydrator;
|
||||
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Hydrator\InvoiceModelActivityHydrator
|
||||
*/
|
||||
class InvoiceModelActivityHydratorTest extends TestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function testHydrate()
|
||||
{
|
||||
$model = $this->getInvoiceModel();
|
||||
|
||||
$sut = new InvoiceModelActivityHydrator();
|
||||
|
||||
$result = $sut->hydrate($model);
|
||||
$this->assertModelStructure($result);
|
||||
|
||||
$model->getQuery()->setActivity(null);
|
||||
$result = $sut->hydrate($model);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
protected function assertModelStructure(array $model)
|
||||
{
|
||||
$keys = [
|
||||
'activity.id',
|
||||
'activity.name',
|
||||
'activity.comment',
|
||||
'activity.fixed_rate',
|
||||
'activity.fixed_rate_nc',
|
||||
'activity.fixed_rate_plain',
|
||||
'activity.hourly_rate',
|
||||
'activity.hourly_rate_nc',
|
||||
'activity.hourly_rate_plain',
|
||||
'activity.meta.foo-activity',
|
||||
];
|
||||
|
||||
$givenKeys = array_keys($model);
|
||||
sort($keys);
|
||||
sort($givenKeys);
|
||||
|
||||
$this->assertEquals($keys, $givenKeys);
|
||||
}
|
||||
}
|
||||
65
tests/Invoice/Hydrator/InvoiceModelCustomerHydratorTest.php
Normal file
65
tests/Invoice/Hydrator/InvoiceModelCustomerHydratorTest.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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\InvoiceModelCustomerHydrator;
|
||||
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Hydrator\InvoiceModelCustomerHydrator
|
||||
*/
|
||||
class InvoiceModelCustomerHydratorTest extends TestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function testHydrate()
|
||||
{
|
||||
$model = $this->getInvoiceModel();
|
||||
|
||||
$sut = new InvoiceModelCustomerHydrator();
|
||||
|
||||
$result = $sut->hydrate($model);
|
||||
$this->assertModelStructure($result);
|
||||
|
||||
$model->setCustomer(null);
|
||||
$result = $sut->hydrate($model);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
protected function assertModelStructure(array $model)
|
||||
{
|
||||
$keys = [
|
||||
'customer.id',
|
||||
'customer.address',
|
||||
'customer.name',
|
||||
'customer.contact',
|
||||
'customer.company',
|
||||
'customer.vat',
|
||||
'customer.country',
|
||||
'customer.number',
|
||||
'customer.homepage',
|
||||
'customer.comment',
|
||||
'customer.fixed_rate',
|
||||
'customer.fixed_rate_nc',
|
||||
'customer.fixed_rate_plain',
|
||||
'customer.hourly_rate',
|
||||
'customer.hourly_rate_nc',
|
||||
'customer.hourly_rate_plain',
|
||||
'customer.meta.foo-customer',
|
||||
];
|
||||
|
||||
$givenKeys = array_keys($model);
|
||||
sort($keys);
|
||||
sort($givenKeys);
|
||||
|
||||
$this->assertEquals($keys, $givenKeys);
|
||||
}
|
||||
}
|
||||
76
tests/Invoice/Hydrator/InvoiceModelDefaultHydratorTest.php
Normal file
76
tests/Invoice/Hydrator/InvoiceModelDefaultHydratorTest.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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\InvoiceModelDefaultHydrator;
|
||||
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Hydrator\InvoiceModelDefaultHydrator
|
||||
*/
|
||||
class InvoiceModelDefaultHydratorTest extends TestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function testHydrate()
|
||||
{
|
||||
$model = $this->getInvoiceModel();
|
||||
|
||||
$sut = new InvoiceModelDefaultHydrator();
|
||||
|
||||
$result = $sut->hydrate($model);
|
||||
$this->assertModelStructure($result);
|
||||
}
|
||||
|
||||
protected function assertModelStructure(array $model, $hasProject = true)
|
||||
{
|
||||
$keys = [
|
||||
'invoice.due_date',
|
||||
'invoice.date',
|
||||
'invoice.number',
|
||||
'invoice.currency',
|
||||
'invoice.currency_symbol',
|
||||
'invoice.vat',
|
||||
'invoice.tax',
|
||||
'invoice.tax_nc',
|
||||
'invoice.tax_plain',
|
||||
'invoice.total_time',
|
||||
'invoice.duration_decimal',
|
||||
'invoice.total',
|
||||
'invoice.total_nc',
|
||||
'invoice.total_plain',
|
||||
'invoice.subtotal',
|
||||
'invoice.subtotal_nc',
|
||||
'invoice.subtotal_plain',
|
||||
'template.name',
|
||||
'template.company',
|
||||
'template.address',
|
||||
'template.title',
|
||||
'template.payment_terms',
|
||||
'template.due_days',
|
||||
'template.vat_id',
|
||||
'template.contact',
|
||||
'template.payment_details',
|
||||
'query.begin',
|
||||
'query.day',
|
||||
'query.end',
|
||||
'query.month',
|
||||
'query.month_number',
|
||||
'query.year',
|
||||
];
|
||||
|
||||
$givenKeys = array_keys($model);
|
||||
sort($keys);
|
||||
sort($givenKeys);
|
||||
|
||||
$this->assertEquals($keys, $givenKeys);
|
||||
}
|
||||
}
|
||||
68
tests/Invoice/Hydrator/InvoiceModelProjectHydratorTest.php
Normal file
68
tests/Invoice/Hydrator/InvoiceModelProjectHydratorTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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\InvoiceModelProjectHydrator;
|
||||
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Hydrator\InvoiceModelProjectHydrator
|
||||
*/
|
||||
class InvoiceModelProjectHydratorTest extends TestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function testHydrate()
|
||||
{
|
||||
$model = $this->getInvoiceModel();
|
||||
|
||||
$sut = new InvoiceModelProjectHydrator();
|
||||
|
||||
$result = $sut->hydrate($model);
|
||||
$this->assertModelStructure($result);
|
||||
|
||||
$model->getQuery()->setProject(null);
|
||||
$result = $sut->hydrate($model);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
protected function assertModelStructure(array $model)
|
||||
{
|
||||
$keys = [
|
||||
'project.id',
|
||||
'project.name',
|
||||
'project.comment',
|
||||
'project.order_date',
|
||||
'project.order_number',
|
||||
'project.fixed_rate',
|
||||
'project.fixed_rate_nc',
|
||||
'project.fixed_rate_plain',
|
||||
'project.hourly_rate',
|
||||
'project.hourly_rate_nc',
|
||||
'project.hourly_rate_plain',
|
||||
'project.meta.foo-project',
|
||||
'project.start_date',
|
||||
'project.end_date',
|
||||
'project.budget_money',
|
||||
'project.budget_money_nc',
|
||||
'project.budget_money_plain',
|
||||
'project.budget_time',
|
||||
'project.budget_time_decimal',
|
||||
'project.budget_time_minutes',
|
||||
];
|
||||
|
||||
$givenKeys = array_keys($model);
|
||||
sort($keys);
|
||||
sort($givenKeys);
|
||||
|
||||
$this->assertEquals($keys, $givenKeys);
|
||||
}
|
||||
}
|
||||
50
tests/Invoice/Hydrator/InvoiceModelUserHydratorTest.php
Normal file
50
tests/Invoice/Hydrator/InvoiceModelUserHydratorTest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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\InvoiceModelUserHydrator;
|
||||
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Hydrator\InvoiceModelUserHydrator
|
||||
*/
|
||||
class InvoiceModelUserHydratorTest extends TestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function testHydrate()
|
||||
{
|
||||
$model = $this->getInvoiceModel();
|
||||
|
||||
$sut = new InvoiceModelUserHydrator();
|
||||
|
||||
$result = $sut->hydrate($model);
|
||||
$this->assertModelStructure($result);
|
||||
}
|
||||
|
||||
protected function assertModelStructure(array $model)
|
||||
{
|
||||
$keys = [
|
||||
'user.alias',
|
||||
'user.email',
|
||||
'user.name',
|
||||
'user.title',
|
||||
'user.meta.hello',
|
||||
'user.meta.kitty',
|
||||
];
|
||||
|
||||
$givenKeys = array_keys($model);
|
||||
sort($keys);
|
||||
sort($givenKeys);
|
||||
|
||||
$this->assertEquals($keys, $givenKeys);
|
||||
}
|
||||
}
|
||||
@@ -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()));
|
||||
|
||||
|
||||
@@ -216,11 +216,11 @@ class ExtensionsTest extends TestCase
|
||||
|
||||
$sut = $this->getSut($this->localeEn);
|
||||
$this->assertEquals('02:37 h', $sut->duration($record->getDuration()));
|
||||
$this->assertEquals('02:37:17 h', $sut->duration($record->getDuration(), '%h:%m:%s h'));
|
||||
$this->assertEquals('2.62', $sut->duration($record->getDuration(), true));
|
||||
|
||||
// test Timesheet object
|
||||
$this->assertEquals('02:37 h', $sut->duration($record));
|
||||
$this->assertEquals('02:37:17', $sut->duration($record, '%h:%m:%s'));
|
||||
$this->assertEquals('2.62', $sut->duration($record, true));
|
||||
|
||||
// test extended format
|
||||
$sut = $this->getSut($this->localeFake, 'XX');
|
||||
@@ -237,6 +237,7 @@ class ExtensionsTest extends TestCase
|
||||
$sut = $this->getSut($this->localeEn, 'en');
|
||||
|
||||
$this->assertEquals('00:00 h', $sut->duration(null));
|
||||
$this->assertEquals('0', $sut->duration(null, true));
|
||||
}
|
||||
|
||||
public function testDurationDecimal()
|
||||
|
||||
Reference in New Issue
Block a user