✨ Story 5.5: endpoint contact PHP
This commit is contained in:
23
tests/contact-api.test.php
Normal file
23
tests/contact-api.test.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
function assertTrue($cond, $msg) {
|
||||
if (!$cond) {
|
||||
fwrite(STDERR, $msg . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
$path = __DIR__ . '/../api/contact.php';
|
||||
assertTrue(file_exists($path), 'missing api/contact.php');
|
||||
$content = file_get_contents($path);
|
||||
|
||||
assertTrue(strpos($content, 'Content-Type: application/json') !== false, 'missing json header');
|
||||
assertTrue(strpos($content, 'X-Content-Type-Options') !== false, 'missing nosniff');
|
||||
assertTrue(strpos($content, "REQUEST_METHOD'] !== 'POST'") !== false, 'missing method check');
|
||||
assertTrue(strpos($content, 'verifyCsrfToken') !== false, 'missing csrf verification');
|
||||
assertTrue(strpos($content, 'verifyRecaptcha') !== false, 'missing recaptcha verification');
|
||||
assertTrue(strpos($content, 'validateContactData') !== false, 'missing data validation');
|
||||
assertTrue(strpos($content, 'sendContactEmail') !== false, 'missing email send');
|
||||
assertTrue(strpos($content, 'success') !== false, 'missing success response');
|
||||
assertTrue(strpos($content, 'error') !== false, 'missing error response');
|
||||
|
||||
fwrite(STDOUT, "OK\n");
|
||||
Reference in New Issue
Block a user