Decision now support auto mailing
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientCase;
|
||||
use App\Models\Person\Person;
|
||||
use App\Services\EmailTemplateRenderer;
|
||||
|
||||
it('renders client.person.full_name and case.person.full_name', function () {
|
||||
$person = new Person(['first_name' => 'Ana', 'last_name' => 'Novak', 'full_name' => 'Ana Novak']);
|
||||
$client = new Client(['id' => 1, 'uuid' => 'c-1']);
|
||||
$client->setRelation('person', $person);
|
||||
|
||||
$case = new ClientCase(['id' => 2, 'uuid' => 'k-2', 'reference' => 'R-2']);
|
||||
$case->setRelation('client', $client);
|
||||
$case->setRelation('person', $person);
|
||||
|
||||
$renderer = app(EmailTemplateRenderer::class);
|
||||
$tpl = [
|
||||
'subject' => '{{ client.person.full_name }} vs {{ case.person.full_name }}',
|
||||
'html' => '<p>{{ client.person.full_name }} - {{ case.person.full_name }}</p>',
|
||||
'text' => '{{ client.person.full_name }}|{{ case.person.full_name }}',
|
||||
];
|
||||
$ctx = [
|
||||
'client' => $client,
|
||||
'client_case' => $case,
|
||||
'person' => $person,
|
||||
];
|
||||
|
||||
$out = $renderer->render($tpl, $ctx);
|
||||
|
||||
expect($out['subject'])->toBe('Ana Novak vs Ana Novak');
|
||||
expect($out['html'])->toContain('Ana Novak - Ana Novak');
|
||||
expect($out['text'])->toBe('Ana Novak|Ana Novak');
|
||||
});
|
||||
Reference in New Issue
Block a user