You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.4 KiB
PHTML
77 lines
2.4 KiB
PHTML
|
1 week ago
|
<?php
|
||
|
|
|
||
|
|
$root = dirname(__DIR__);
|
||
|
|
$assert = static function ($condition, string $message): void {
|
||
|
|
if (!$condition) {
|
||
|
|
throw new RuntimeException($message);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$contracts = [
|
||
|
|
'app/Controllers/AuthController.php' => [
|
||
|
|
"'Login Verification'",
|
||
|
|
"\$subject = 'Email Verification';",
|
||
|
|
],
|
||
|
|
'app/Services/AccountSecurityService.php' => [
|
||
|
|
"'Password Change Verification'",
|
||
|
|
],
|
||
|
|
'app/Services/AccountEmailChangeService.php' => [
|
||
|
|
"'Email Change Verification'",
|
||
|
|
],
|
||
|
|
'app/Services/Password.php' => [
|
||
|
|
"\$subject = 'Password Reset';",
|
||
|
|
],
|
||
|
|
'app/Services/Cloud/CloudInvoiceService.php' => [
|
||
|
|
"'Renewal Invoice Created'",
|
||
|
|
"'Instance Provisioned'",
|
||
|
|
],
|
||
|
|
'app/Services/Cloud/CloudServiceCompensationNotificationService.php' => [
|
||
|
|
"'subject' => 'Service Time Compensation Applied'",
|
||
|
|
],
|
||
|
|
'app/Services/Ticket/TicketNotificationDispatcher.php' => [
|
||
|
|
"'Ticket Created'",
|
||
|
|
"'New Ticket: ' . (string) \$root->title",
|
||
|
|
"'Ticket Reply Received'",
|
||
|
|
],
|
||
|
|
'app/Controllers/Admin/UserController.php' => [
|
||
|
|
"'Account Created'",
|
||
|
|
"\$subject = trim((string) \$subjectFromFrontEnd);",
|
||
|
|
],
|
||
|
|
'app/Command/Job.php' => [
|
||
|
|
"'Database Backup'",
|
||
|
|
],
|
||
|
|
];
|
||
|
|
|
||
|
|
$sources = [];
|
||
|
|
foreach ($contracts as $relative => $needles) {
|
||
|
|
$source = file_get_contents($root . '/' . $relative);
|
||
|
|
$assert(is_string($source), 'Unable to read mail subject source: ' . $relative);
|
||
|
|
foreach ($needles as $needle) {
|
||
|
|
$assert(
|
||
|
|
str_contains($source, $needle),
|
||
|
|
'A required event-only English subject contract is missing in '
|
||
|
|
. $relative . ': ' . $needle
|
||
|
|
);
|
||
|
|
}
|
||
|
|
$sources[] = $source;
|
||
|
|
}
|
||
|
|
|
||
|
|
$combined = implode("\n", $sources);
|
||
|
|
$assert(
|
||
|
|
preg_match(
|
||
|
|
'/(?:Config::get\([\'\"]appName[\'\"]\)|\$appName)\s*\.\s*[\'\"][^\'\"]*[-–—]/',
|
||
|
|
$combined
|
||
|
|
) !== 1,
|
||
|
|
'A system email subject still prepends the site title.'
|
||
|
|
);
|
||
|
|
|
||
|
|
$authEntries = file_get_contents(
|
||
|
|
$root . '/resources/user-copy/entries/auth.entries.php'
|
||
|
|
);
|
||
|
|
$assert(is_string($authEntries)
|
||
|
|
&& !str_contains($authEntries, 'auth.login.verify.subject')
|
||
|
|
&& !str_contains($authEntries, 'auth.register.verify.subject'),
|
||
|
|
'Retired localized email-subject keys are still present in user copy.');
|
||
|
|
|
||
|
|
echo 'Event-only English mail subject contracts passed.' . PHP_EOL;
|