20 lines
765 B
PHP
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"); |