Release 2.33.0 (#5438)
This commit is contained in:
@@ -12,6 +12,7 @@ namespace App\Tests\Invoice\Hydrator;
|
||||
use App\Invoice\Hydrator\InvoiceModelDefaultHydrator;
|
||||
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionObject;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Hydrator\InvoiceModelDefaultHydrator
|
||||
@@ -30,6 +31,23 @@ class InvoiceModelDefaultHydratorTest extends TestCase
|
||||
$this->assertModelStructure($result);
|
||||
}
|
||||
|
||||
public function testHydrateThrowsOnMissing(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('InvoiceModel needs a template');
|
||||
|
||||
$model = $this->getInvoiceModel();
|
||||
|
||||
$obj = new ReflectionObject($model);
|
||||
$prop = $obj->getProperty('template');
|
||||
$prop->setAccessible(true);
|
||||
$prop->setValue($model, null);
|
||||
|
||||
$sut = new InvoiceModelDefaultHydrator();
|
||||
|
||||
$sut->hydrate($model);
|
||||
}
|
||||
|
||||
protected function assertModelStructure(array $model, bool $hasProject = true): void
|
||||
{
|
||||
$keys = [
|
||||
@@ -60,6 +78,8 @@ class InvoiceModelDefaultHydratorTest extends TestCase
|
||||
'invoice.subtotal_plain',
|
||||
'template.name',
|
||||
'template.company',
|
||||
'template.country',
|
||||
'template.country_name',
|
||||
'template.address',
|
||||
'template.title',
|
||||
'template.payment_terms',
|
||||
|
||||
Reference in New Issue
Block a user