mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

Given that Windows ignores trailing dots and spaces in filenames, we catch that ourselves to avoid confusion with the respective filenames without these characters. Closes GH-9229.
35 lines
757 B
PHP
35 lines
757 B
PHP
--TEST--
|
|
SPL: SplFileInfo::getExtension() basic test
|
|
--SKIPIF--
|
|
<?php
|
|
if (PHP_OS_FAMILY === "Windows") die("skip not for Windows");
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
$file = md5('SplFileInfo::getExtension');
|
|
$exts = array('.txt', '.extension', '..', '.', '');
|
|
foreach ($exts as $ext) {
|
|
touch($file . $ext);
|
|
$info = new SplFileInfo($file . $ext);
|
|
var_dump($info->getExtension(), pathinfo($file . $ext, PATHINFO_EXTENSION));
|
|
}
|
|
?>
|
|
--CLEAN--
|
|
<?php
|
|
$file = md5('SplFileInfo::getExtension');
|
|
$exts = array('.txt', '.extension', '..', '.', '');
|
|
foreach ($exts as $ext) {
|
|
@unlink($file . $ext);
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
string(3) "txt"
|
|
string(3) "txt"
|
|
string(9) "extension"
|
|
string(9) "extension"
|
|
string(0) ""
|
|
string(0) ""
|
|
string(0) ""
|
|
string(0) ""
|
|
string(0) ""
|
|
string(0) ""
|