This commit is contained in:
baodev0
2026-10-05 09:30:24 +07:00
parent a1aeb88061
commit 1544629a1f
53 changed files with 1292 additions and 963 deletions
+24
View File
@@ -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']);
}
}