Files
Portfolio-Codex/tests/images.test.php
2026-02-04 17:17:51 +01:00

20 lines
765 B
PHP

<?php
require_once __DIR__ . '/../includes/functions.php';
function assertTrue($cond, $msg) {
if (!$cond) {
fwrite(STDERR, $msg . PHP_EOL);
exit(1);
}
}
$htmlLazy = projectImage('ecommerce-xyz-thumb.webp', 'Test', 400, 225, true);
assertTrue(strpos($htmlLazy, 'loading="lazy"') !== false, 'lazy attr missing');
assertTrue(strpos($htmlLazy, 'type="image/webp"') !== false, 'webp source missing');
assertTrue(strpos($htmlLazy, 'width="400"') !== false, 'width missing');
assertTrue(strpos($htmlLazy, 'height="225"') !== false, 'height missing');
$htmlNoLazy = projectImage('ecommerce-xyz-thumb.webp', 'Test', 400, 225, false);
assertTrue(strpos($htmlNoLazy, 'loading="lazy"') === false, 'lazy should be absent');
fwrite(STDOUT, "OK\n");