34 lines
1.6 KiB
PHP
34 lines
1.6 KiB
PHP
<?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>'));
|
|
}
|
|
}
|