40 lines
1 KiB
Text
40 lines
1 KiB
Text
|
|
--TEST--
|
||
|
|
buildBreadcrumbs: skips non-existent directories gracefully
|
||
|
|
--FILE--
|
||
|
|
<?php
|
||
|
|
require '/var/www/app/context.php';
|
||
|
|
require '/var/www/app/hooks.php';
|
||
|
|
require '/var/www/app/constants.php';
|
||
|
|
require '/var/www/app/helpers.php';
|
||
|
|
require '/var/www/app/content.php';
|
||
|
|
|
||
|
|
// Create temp directory structure with only level 1
|
||
|
|
$tempBase = sys_get_temp_dir() . '/phpt_' . getmypid();
|
||
|
|
$tempContent = $tempBase . '/content';
|
||
|
|
$tempLevel1 = $tempContent . '/nyheter';
|
||
|
|
|
||
|
|
mkdir($tempLevel1, 0777, true);
|
||
|
|
file_put_contents($tempLevel1 . '/metadata.ini', "title = Nyheter\n");
|
||
|
|
|
||
|
|
// Request path has middle directories that don't exist
|
||
|
|
$ctx = new Context(
|
||
|
|
contentDir: $tempContent,
|
||
|
|
templates: new Templates('/tmp/base.php', '/tmp/page.php', '/tmp/list.php'),
|
||
|
|
requestPath: 'nyheter/nonexistent/artikkel',
|
||
|
|
hasTrailingSlash: false
|
||
|
|
);
|
||
|
|
|
||
|
|
$result = buildBreadcrumbs($ctx);
|
||
|
|
|
||
|
|
// Only nyheter exists, so only 1 breadcrumb
|
||
|
|
echo count($result) . "\n";
|
||
|
|
|
||
|
|
// Cleanup
|
||
|
|
unlink($tempLevel1 . '/metadata.ini');
|
||
|
|
rmdir($tempLevel1);
|
||
|
|
rmdir($tempContent);
|
||
|
|
rmdir($tempBase);
|
||
|
|
?>
|
||
|
|
--EXPECT--
|
||
|
|
1
|