Update framework testing infrastructure and standards
- 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
This commit is contained in:
parent
33943a907b
commit
449e6f8e03
22 changed files with 909 additions and 7 deletions
42
devel/tests/helpers/find_page_css.phpt
Normal file
42
devel/tests/helpers/find_page_css.phpt
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
--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
|
||||
Loading…
Add table
Add a link
Reference in a new issue