update
This commit is contained in:
@@ -111,4 +111,28 @@ class EmailTemplateRendererTest extends TestCase
|
||||
$this->assertStringNotContainsString('49', $result['html']);
|
||||
$this->assertStringContainsString('<?php', $result['html']);
|
||||
}
|
||||
|
||||
public function test_dollar_placeholders_are_declared_on_sync_and_rendered_with_default(): void
|
||||
{
|
||||
$template = $this->makeTemplate(
|
||||
'Ưu đãi {{$promo_code}}',
|
||||
'<p>{{ $promo_code }} cho {{full_name}}</p>{{$content}}',
|
||||
[
|
||||
['key' => 'full_name', 'label' => 'Họ tên', 'type' => 'string'],
|
||||
['key' => 'old_custom', 'label' => 'Cũ', 'type' => 'string', 'custom' => true],
|
||||
],
|
||||
);
|
||||
|
||||
$template->syncVariables([['key' => 'promo_code', 'label' => 'Mã KM', 'example' => 'TGS10']]);
|
||||
$variables = $template->variables();
|
||||
|
||||
$this->assertSame(['full_name', 'promo_code'], array_keys($variables));
|
||||
$this->assertSame('Mã KM', $variables['promo_code']['label']);
|
||||
$this->assertTrue($variables['promo_code']['custom']);
|
||||
|
||||
$result = (new EmailTemplateRenderer())->render($template, ['full_name' => 'An']);
|
||||
|
||||
$this->assertSame('Ưu đãi TGS10', $result['subject']);
|
||||
$this->assertSame('<p>TGS10 cho An</p>{{$content}}', $result['html']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user