notify(new GenericNotification( type: 'welcome', hookPrefix: 'core.auth', data: ['name' => $name], extensionType: 'core', extensionIdentifier: 'core', channel: 'mail', )); } public function test_guest_mail_send_is_logged_with_null_user_id_and_email_identifier(): void { $this->sendGuestMail('guest@example.com', '비회원주문자'); $log = NotificationLog::where('channel', 'mail') ->where('recipient_identifier', 'guest@example.com') ->first(); $this->assertNotNull($log, '비회원 mail 발송이 notification_logs 에 기록되어야 한다.'); // 게스트는 users FK 가 없으므로 recipient_user_id 는 null 이어야 한다 (합성 키 문자열 미삽입). $this->assertNull($log->recipient_user_id); $this->assertSame('비회원주문자', $log->recipient_name); } public function test_guest_database_channel_is_not_logged_as_sent(): void { // database 채널은 allow_guest=false 게이트로 via() 가 빈 배열을 반환 → 발송 안 됨. $guest = new GuestNotifiable('guest-db@example.com', '비회원', 'ko'); $guest->notify(new GenericNotification( type: 'welcome', hookPrefix: 'core.auth', data: ['name' => '비회원'], extensionType: 'core', extensionIdentifier: 'core', channel: 'database', )); // database 채널로 발송 성공 기록이 없어야 한다 (게이트 차단). $sent = NotificationLog::where('channel', 'database') ->where('recipient_identifier', 'guest-db@example.com') ->where('status', '!=', 'skipped') ->count(); $this->assertSame(0, $sent, '비회원 database 발송은 게이트로 차단되어 발송 기록이 없어야 한다.'); // 사이트내(database) 알림 morph 테이블에도 게스트 행이 생기지 않아야 한다. $this->assertDatabaseCount('notifications', 0); } }