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
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace Tests\Unit;
use App\Support\EmailScenarioRegistry;
use PHPUnit\Framework\TestCase;
class EmailScenarioRegistryTest extends TestCase
{
public function test_registered_scenario_is_locked_and_custom_template_is_marketing(): void
{
$system = EmailScenarioRegistry::describe(null, 'customer_password_reset_link');
$this->assertTrue($system['registered']);
$this->assertSame('TRANSACTIONAL', $system['category']);
$this->assertSame(['edit_content' => true, 'delete' => false, 'change_key' => false, 'disable' => false], $system['permissions']);
$this->assertTrue(EmailScenarioRegistry::describe('order_created')['permissions']['disable']);
$custom = EmailScenarioRegistry::describe('promo_thang_10', 'promo');
$this->assertFalse($custom['registered']);
$this->assertSame('MARKETING', $custom['category']);
$this->assertTrue($custom['permissions']['delete']);
}
public function test_missing_variables_accepts_both_syntaxes_and_layout_slot(): void
{
$this->assertSame([], EmailScenarioRegistry::missingVariables(['reset_url'], 'x', '<a href="{{ $reset_url }}">'));
$this->assertSame([], EmailScenarioRegistry::missingVariables(['reset_url'], 'Link {{reset_url}}', ''));
$this->assertSame(['reset_url'], EmailScenarioRegistry::missingVariables(['reset_url'], 'x', '<p>Đặt lại mật khẩu</p>'));
$this->assertSame([], EmailScenarioRegistry::missingVariables(['content'], null, '<table>{{$content}}</table>'));
$this->assertSame(['content'], EmailScenarioRegistry::missingVariables(['content'], null, '<table></table>'));
}
}