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
36
devel/tests/helpers/find_page_js.phpt
Normal file
36
devel/tests/helpers/find_page_js.phpt
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
--TEST--
|
||||
findPageJs: returns URL and hash for script.js, null when absent
|
||||
--FILE--
|
||||
<?php
|
||||
require '/var/www/app/helpers.php';
|
||||
|
||||
$contentDir = sys_get_temp_dir() . '/phpt_js_' . getmypid();
|
||||
$pageDir = "$contentDir/section/page";
|
||||
mkdir($pageDir, 0777, true);
|
||||
|
||||
// No script.js
|
||||
echo (findPageJs($pageDir, $contentDir) ?? 'null') . "\n";
|
||||
|
||||
// Add script.js
|
||||
file_put_contents("$pageDir/script.js", 'console.log("hi");');
|
||||
$result = findPageJs($pageDir, $contentDir);
|
||||
echo $result['url'] . "\n";
|
||||
echo ($result['hash'] === md5_file("$pageDir/script.js") ? 'hash ok' : 'hash mismatch') . "\n";
|
||||
|
||||
// Root-level page (no subpath)
|
||||
$rootJs = "$contentDir/script.js";
|
||||
file_put_contents($rootJs, '');
|
||||
$result = findPageJs($contentDir, $contentDir);
|
||||
echo $result['url'] . "\n";
|
||||
|
||||
unlink("$pageDir/script.js");
|
||||
unlink($rootJs);
|
||||
rmdir($pageDir);
|
||||
rmdir("$contentDir/section");
|
||||
rmdir($contentDir);
|
||||
?>
|
||||
--EXPECT--
|
||||
null
|
||||
/section/page/script.js
|
||||
hash ok
|
||||
/script.js
|
||||
Loading…
Add table
Add a link
Reference in a new issue