- Add phpt test runner and suite for app functions - Introduce testing workflow to AGENT.md - Add tests for cache, content, context, helpers, hooks, plugins, rendering - Mount tests directory in dev container
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
--TEST--
|
|
findPageCss: returns URL and hash for styles.css, null when absent
|
|
--FILE--
|
|
<?php
|
|
require '/var/www/app/helpers.php';
|
|
|
|
$contentDir = sys_get_temp_dir() . '/phpt_css_' . getmypid();
|
|
$pageDir = "$contentDir/blog/post";
|
|
mkdir($pageDir, 0777, true);
|
|
|
|
// No styles.css
|
|
echo (findPageCss($pageDir, $contentDir) ?? 'null') . "\n";
|
|
|
|
// Add styles.css
|
|
file_put_contents("$pageDir/styles.css", 'body { color: red; }');
|
|
$result = findPageCss($pageDir, $contentDir);
|
|
echo $result['url'] . "\n";
|
|
echo ($result['hash'] === md5_file("$pageDir/styles.css") ? 'hash ok' : 'hash mismatch') . "\n";
|
|
|
|
// Root-level page (no subpath)
|
|
$rootCss = "$contentDir/styles.css";
|
|
file_put_contents($rootCss, 'body {}');
|
|
$result = findPageCss($contentDir, $contentDir);
|
|
echo $result['url'] . "\n";
|
|
|
|
// Directory named styles.css is ignored
|
|
unlink("$pageDir/styles.css");
|
|
mkdir("$pageDir/styles.css");
|
|
echo (findPageCss($pageDir, $contentDir) ?? 'null') . "\n";
|
|
|
|
rmdir("$pageDir/styles.css");
|
|
unlink($rootCss);
|
|
rmdir($pageDir);
|
|
rmdir("$contentDir/blog");
|
|
rmdir($contentDir);
|
|
?>
|
|
--EXPECT--
|
|
null
|
|
/blog/post/styles.css
|
|
hash ok
|
|
/styles.css
|
|
null
|