'test@example.com', 'name' => 'Test User']); $channels = $notification->via($user); $this->assertContains('mail', $channels); } /** * toMail()이 DbTemplateMail을 반환하는지 확인 */ public function test_to_mail_returns_db_template_mail(): void { MailTemplate::factory()->withType('welcome')->create(); $notification = new WelcomeNotification(); $user = User::factory()->create(['email' => 'test@example.com', 'name' => 'Test User']); $mailable = $notification->toMail($user); $this->assertInstanceOf(DbTemplateMail::class, $mailable); } /** * Mailable의 templateType이 welcome인지 확인 */ public function test_mailable_template_type_is_welcome(): void { MailTemplate::factory()->withType('welcome')->create(); $notification = new WelcomeNotification(); $user = User::factory()->create(); $mailable = $notification->toMail($user); $this->assertEquals('welcome', $mailable->getTemplateType()); } /** * Mailable의 module이 core인지 확인 */ public function test_mailable_module_is_core(): void { MailTemplate::factory()->withType('welcome')->create(); $notification = new WelcomeNotification(); $user = User::factory()->create(); $mailable = $notification->toMail($user); $this->assertEquals(ExtensionOwnerType::Core, $mailable->getExtensionType()); $this->assertEquals('core', $mailable->getExtensionIdentifier()); } /** * 비활성 템플릿에서 스킵 인스턴스 반환 */ public function test_to_mail_returns_skipped_when_template_inactive(): void { MailTemplate::factory()->withType('welcome')->inactive()->create(); $notification = new WelcomeNotification(); $user = User::factory()->create(); $mailable = $notification->toMail($user); $this->assertInstanceOf(DbTemplateMail::class, $mailable); $this->assertTrue($mailable->isSkipped()); } /** * 템플릿 미존재 시 스킵 인스턴스 반환 */ public function test_to_mail_returns_skipped_when_no_template(): void { $notification = new WelcomeNotification(); $user = User::factory()->create(); $mailable = $notification->toMail($user); $this->assertInstanceOf(DbTemplateMail::class, $mailable); $this->assertTrue($mailable->isSkipped()); } }