folderweb/devel/tests/helpers/get_subdirectories.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

39 lines
819 B
PHP

--TEST--
getSubdirectories: returns only subdirectory names, ignores files
--FILE--
<?php
require '/var/www/app/helpers.php';
$dir = sys_get_temp_dir() . '/phpt_subdirs_' . getmypid();
mkdir($dir);
// Empty directory
$result = getSubdirectories($dir);
echo (empty($result) ? 'empty' : 'not empty') . "\n";
// Non-existent directory
echo count(getSubdirectories($dir . '/nope')) . "\n";
// Add subdirectories and a file
mkdir("$dir/alpha");
mkdir("$dir/beta");
touch("$dir/file.txt");
$result = array_values(getSubdirectories($dir));
sort($result);
echo implode("\n", $result) . "\n";
// Files are not included
echo in_array('file.txt', $result) ? "file included\n" : "file excluded\n";
unlink("$dir/file.txt");
rmdir("$dir/alpha");
rmdir("$dir/beta");
rmdir($dir);
?>
--EXPECT--
empty
0
alpha
beta
file excluded