Add superuser new customer email notification preferences
This commit is contained in:
@@ -150,10 +150,12 @@ namespace classes {
|
||||
class email
|
||||
{
|
||||
public static array $sent = [];
|
||||
public static array $superuser_notifications = [];
|
||||
|
||||
public static function reset(): void
|
||||
{
|
||||
self::$sent = [];
|
||||
self::$superuser_notifications = [];
|
||||
}
|
||||
|
||||
public function sendWelcomeEmailToCustomer($phone, $email): bool
|
||||
@@ -166,6 +168,16 @@ namespace classes {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function sendNewCustomerRegistrationNotifications($phone): bool
|
||||
{
|
||||
self::$superuser_notifications[] = [
|
||||
'customer_number' => (int)$phone,
|
||||
];
|
||||
\objects\users_o::$interaction_log[] = 'superuser-notification:' . (int)$phone;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class authentication
|
||||
@@ -370,6 +382,7 @@ namespace {
|
||||
'assert' => static function (): void {
|
||||
assert_true(count(\classes\economic::$create_calls) === 0, 'Fresh create must not run for local duplicates.');
|
||||
assert_true(count(\classes\email::$sent) === 0, 'Duplicate registrations must not send welcome emails.');
|
||||
assert_true(count(\classes\email::$superuser_notifications) === 0, 'Duplicate registrations must not send superuser notifications.');
|
||||
},
|
||||
],
|
||||
[
|
||||
@@ -395,6 +408,8 @@ namespace {
|
||||
assert_true(\objects\users_o::$interaction_log[0] === 'bootstrap:12345678', 'Local bootstrap must happen before sending emails.');
|
||||
assert_true(\classes\email::$sent[0]['email'] === 'jm@truckwash.dk', 'Recovery should notify the internal welcome recipient first.');
|
||||
assert_true(\classes\email::$sent[1]['email'] === 'test@test.com', 'Recovery should notify the invoice email.');
|
||||
assert_true(count(\classes\email::$superuser_notifications) === 1, 'Recovery must notify opted-in superusers once.');
|
||||
assert_true(\classes\email::$superuser_notifications[0]['customer_number'] === 12345678, 'Recovery superuser notification must use the recovered customer number.');
|
||||
},
|
||||
],
|
||||
[
|
||||
@@ -413,6 +428,7 @@ namespace {
|
||||
'expected_status' => 400,
|
||||
'assert' => static function (): void {
|
||||
assert_true(count(\classes\email::$sent) === 0, 'Duplicate recovery attempts must not send welcome emails.');
|
||||
assert_true(count(\classes\email::$superuser_notifications) === 0, 'Duplicate recovery attempts must not send superuser notifications.');
|
||||
},
|
||||
],
|
||||
[
|
||||
@@ -431,6 +447,7 @@ namespace {
|
||||
'assert' => static function (): void {
|
||||
assert_true(count(\classes\economic::$create_calls) === 0, 'Conflict on existing mismatched customer must not trigger create.');
|
||||
assert_true(count(\classes\email::$sent) === 0, 'Conflict on existing mismatched customer must not send welcome emails.');
|
||||
assert_true(count(\classes\email::$superuser_notifications) === 0, 'Conflict on existing mismatched customer must not send superuser notifications.');
|
||||
assert_true(count(\objects\logs_o::$entries) === 1, 'Conflict should be logged for manual cleanup.');
|
||||
},
|
||||
],
|
||||
@@ -461,6 +478,8 @@ namespace {
|
||||
assert_true(count(\classes\email::$sent) === 2, 'Fresh registration must send two welcome emails.');
|
||||
assert_true(\objects\users_o::$interaction_log[0] === 'bootstrap:12345678', 'Fresh registration must bootstrap the local user before emails.');
|
||||
assert_true(\classes\email::$sent[0]['email'] === 'jm@truckwash.dk', 'Fresh registration should notify the internal welcome recipient first.');
|
||||
assert_true(count(\classes\email::$superuser_notifications) === 1, 'Fresh registration must notify opted-in superusers once.');
|
||||
assert_true(\classes\email::$superuser_notifications[0]['customer_number'] === 12345678, 'Fresh registration superuser notification must use the created customer number.');
|
||||
},
|
||||
],
|
||||
[
|
||||
@@ -479,6 +498,7 @@ namespace {
|
||||
assert_true(count(\classes\economic::$create_calls) === 1, 'Create mismatch must still record the attempted create call.');
|
||||
assert_true(count(\objects\users_o::$interaction_log) === 0, 'Create mismatch must not bootstrap the wrong local customer.');
|
||||
assert_true(count(\classes\email::$sent) === 0, 'Create mismatch must not send welcome emails.');
|
||||
assert_true(count(\classes\email::$superuser_notifications) === 0, 'Create mismatch must not send superuser notifications.');
|
||||
assert_true(count(\objects\logs_o::$entries) === 1, 'Create mismatch should be logged for manual cleanup.');
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user