folderweb/devel/tests/helpers/find_pdf_file.phpt

29 lines
511 B
Text
Raw Normal View History

--TEST--
findPdfFile: finds first .pdf file in a directory
--FILE--
<?php
require '/var/www/app/helpers.php';
$dir = sys_get_temp_dir() . '/phpt_pdf_' . getmypid();
mkdir($dir);
// No PDF
echo (findPdfFile($dir) ?? 'null') . "\n";
// One PDF
touch("$dir/document.pdf");
echo findPdfFile($dir) . "\n";
// Non-PDF files are ignored
touch("$dir/image.jpg");
touch("$dir/notes.txt");
echo findPdfFile($dir) . "\n";
array_map('unlink', glob("$dir/*"));
rmdir($dir);
?>
--EXPECT--
null
document.pdf
document.pdf