Merge branch 'master' into feat/TRU-149-route-scopes
This commit is contained in:
@@ -32,7 +32,7 @@ class email_template_stripe_invoice
|
||||
|
||||
<!-- Email template -->
|
||||
<p>Kære <?= $this->name ?>,</p>
|
||||
<p>Tak for din bestilling hos Truck Wash. Vi har sendt dig en faktura på Stripe.
|
||||
<p>Tak for din bestilling hos Truck Wash. Vi har sendt dig et betalingslink til din faktura.
|
||||
Du kan betale fakturaen ved at klikke på linket nedenfor:</p>
|
||||
<p><a href="<?= $this->stripe_payment_link ?>">Betal faktura for ordre <?= $this->order_id ?></a></p>
|
||||
<!-- End of the email template -->
|
||||
|
||||
@@ -6,6 +6,7 @@ return [
|
||||
['path' => 'tests/auth/PasskeyChallengeTest.php', 'classification' => 'unit', 'type' => 'script'],
|
||||
['path' => 'tests/auth/PemToCoseConversionTest.php', 'classification' => 'unit', 'type' => 'script'],
|
||||
['path' => 'tests/auth/RegisterCvrTest.php', 'classification' => 'unit', 'type' => 'script'],
|
||||
['path' => 'tests/auth/StripeInvoiceEmailTemplateTest.php', 'classification' => 'unit', 'type' => 'script'],
|
||||
['path' => 'tests/auth/TwoFactorAuthTest.php', 'classification' => 'integration', 'type' => 'script'],
|
||||
['path' => 'tests/auth/WebAuthnInstallTest.php', 'classification' => 'unit', 'type' => 'script'],
|
||||
['path' => 'tests/bookingModule/BookingModuleTest.php', 'classification' => 'unit', 'type' => 'script'],
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
namespace {
|
||||
if (!defined('WD')) {
|
||||
define('WD', dirname(__DIR__, 2));
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
require_once WD . '/modules/email/helpers/email_template.php';
|
||||
require_once WD . '/modules/email/templates/email_template_stripe_invoice.php';
|
||||
|
||||
function assert_true(bool $condition, string $message): void
|
||||
{
|
||||
if (!$condition) {
|
||||
throw new \RuntimeException($message);
|
||||
}
|
||||
}
|
||||
|
||||
function cleanup_buffers_to(int $base_level): string
|
||||
{
|
||||
$output = '';
|
||||
while (ob_get_level() > $base_level) {
|
||||
$output .= (string)ob_get_clean();
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
$base_level = ob_get_level();
|
||||
ob_start();
|
||||
|
||||
try {
|
||||
$html = (new \email\templates\email_template_stripe_invoice(
|
||||
4242,
|
||||
'https://pay.example.com/invoice/abc',
|
||||
'Anders And'
|
||||
))->generate_html();
|
||||
$leaked_output = cleanup_buffers_to($base_level);
|
||||
|
||||
assert_true($leaked_output === '', 'Template generation must not leak buffered HTML output.');
|
||||
|
||||
// TRU-71: user-facing wording must not mention the payment processor
|
||||
// by name. The email body must describe the artefact in plain
|
||||
// language instead.
|
||||
assert_true(
|
||||
stripos($html, 'stripe') === false,
|
||||
'Stripe-invoice email body must no longer expose the payment processor name "Stripe" to the customer.'
|
||||
);
|
||||
|
||||
assert_true(
|
||||
str_contains($html, 'betalingslink'),
|
||||
'Stripe-invoice email body must describe the artefact as a betalingslink (payment link).'
|
||||
);
|
||||
|
||||
assert_true(
|
||||
str_contains($html, 'Kære Anders And'),
|
||||
'Template must still greet the customer by name.'
|
||||
);
|
||||
|
||||
assert_true(
|
||||
str_contains($html, 'Betal faktura for ordre 4242'),
|
||||
'Template must still expose a pay-now action link for the order.'
|
||||
);
|
||||
} catch (\Throwable $exception) {
|
||||
$leaked_output = cleanup_buffers_to($base_level);
|
||||
fwrite(STDERR, $leaked_output);
|
||||
fwrite(STDERR, $exception->getMessage() . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "\033[32m[PASS]\033[0m Stripe-invoice email template no longer mentions Stripe to the customer.\n";
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user