Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SassTask] [core] - Fixed Filesystem::listContents for numeric filenames. #1511

Merged
merged 7 commits into from
Jan 26, 2021
4 changes: 2 additions & 2 deletions src/Phing/Io/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,14 +869,14 @@ public function compareMTimes($file1, $file2)
*/
public function listContents(File $f)
{
return array_keys(
return array_map('strval', array_keys(
iterator_to_array(
new FilesystemIterator(
$f->getAbsolutePath(),
FilesystemIterator::KEY_AS_FILENAME
)
)
);
));
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/Phing/Io/FileSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,16 @@ public function testWhichHinkyExecutableNameWithSeparator()
$path = $fs->which('zx:\tasword.bin');
$this->assertEquals($path, false);
}

public function testListContentsWithNumericName()
{
$fs = FileSystem::getFileSystem();

$parentDir = new File(__DIR__ . '/../../etc/system/io/testdir');
$contents = $fs->listContents($parentDir);

foreach ($contents as $filename) {
self::assertIsString($filename);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ public function testItNotProducesAnyCompiledOutputWhenNoInput(): void

public function testItThrowsExceptionWhenFailOnErrorIsSet(): void
{
$this->expectException(BuildException::class);

$this->compiler->compile(
self::SASS_TEST_BASE . 'non-existing.sass',
self::SASS_TEST_BASE . 'test.css',
true
);

$this->expectException(BuildException::class);

$this->assertFileDoesNotExist(self::SASS_TEST_BASE . 'test.css');
}
}
Empty file added tests/etc/system/io/testdir/111
Empty file.