folderweb/devel/tests/content/load_metadata.phpt
Ruben 449e6f8e03 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
2026-03-17 12:51:07 +01:00

44 lines
1.1 KiB
PHP

--TEST--
loadMetadata: parses metadata.ini, returns null when absent
--FILE--
<?php
require '/var/www/app/hooks.php';
require '/var/www/app/content.php';
$dir = sys_get_temp_dir() . '/phpt_meta_' . getmypid();
mkdir($dir);
// No metadata file
echo (loadMetadata($dir) ?? 'null') . "\n";
// Basic key-value metadata
file_put_contents("$dir/metadata.ini", "title = My Page\nsummary = A summary\nmenu = true\n");
$meta = loadMetadata($dir);
echo $meta['title'] . "\n";
echo $meta['summary'] . "\n";
echo $meta['menu'] . "\n";
// _raw is always present
echo isset($meta['_raw']) ? 'raw present' : 'raw missing';
echo "\n";
// Sections are in _raw but not in base metadata
file_put_contents("$dir/metadata.ini", "[en]\ntitle = English Title\n\n[fr]\ntitle = French Title\n");
$meta = loadMetadata($dir);
echo isset($meta['en']) ? 'section leaked' : 'section contained';
echo "\n";
echo $meta['_raw']['en']['title'] . "\n";
echo $meta['_raw']['fr']['title'] . "\n";
array_map('unlink', glob("$dir/*"));
rmdir($dir);
?>
--EXPECT--
null
My Page
A summary
1
raw present
section contained
English Title
French Title