Skip to content

Commit fb86f72

Browse files
committed
test: add test for get_dir_file_info with topLevelOnly=true when get_file_info returns null
1 parent 8143411 commit fb86f72

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/system/Helpers/FilesystemHelperTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,22 @@ public function testGetDirFileInfoFailure(): void
477477
$this->assertSame($expected, get_dir_file_info(SUPPORTPATH . 'Files#baker'));
478478
}
479479

480+
public function testGetDirFileInfoIgnoresDirectoriesWhenTopLevelOnlyIsTrue(): void
481+
{
482+
$dir = WRITEPATH . 'test_get_dir_file_info';
483+
mkdir($dir . '/subdir', 0777, true);
484+
file_put_contents($dir . '/file.txt', 'test');
485+
486+
$result = get_dir_file_info($dir, true);
487+
488+
unlink($dir . '/file.txt');
489+
rmdir($dir . '/subdir');
490+
rmdir($dir);
491+
492+
$this->assertArrayHasKey('file.txt', $result);
493+
$this->assertArrayNotHasKey('subdir', $result);
494+
}
495+
480496
public function testGetFileInfo(): void
481497
{
482498
$file = SUPPORTPATH . 'Files/baker/banana.php';

0 commit comments

Comments
 (0)