Fix tests on Windows (#288)

This commit is contained in:
Adrien Loison authored and GitHub committed 2016-08-10 12:09:37 -07:00
1 parent 7f65993c87
commit b2dc0c3fa9
3 files changed
+23 -5

No files matched your search

+7 -2
View File
@@ -138,11 +138,12 @@ class XMLReaderTest extends \PHPUnit_Framework_TestCase
public function dataProviderForTestGetRealPathURIForFileInZip()
{
$tempFolder = realpath(sys_get_temp_dir());
$tempFolderName = basename($tempFolder);
$expectedRealPathURI = 'zip://' . $tempFolder . '/test.xlsx#test.xml';
return [
[$tempFolder, "$tempFolder/test.xlsx", 'test.xml', $expectedRealPathURI],
[$tempFolder, "/../../../$tempFolder/test.xlsx", 'test.xml', $expectedRealPathURI],
[$tempFolder, "$tempFolder/../$tempFolderName/test.xlsx", 'test.xml', $expectedRealPathURI],
];
}
@@ -162,7 +163,11 @@ class XMLReaderTest extends \PHPUnit_Framework_TestCase
$xmlReader = new XMLReader();
$realPathURI = \ReflectionHelper::callMethodOnObject($xmlReader, 'getRealPathURIForFileInZip', $zipFilePath, $fileInsideZipPath);
$this->assertEquals($expectedRealPathURI, $realPathURI);
// Normalizing path separators for Windows support
$normalizedRealPathURI = str_replace('\\', '/', $realPathURI);
$normalizedExpectedRealPathURI = str_replace('\\', '/', $expectedRealPathURI);
$this->assertEquals($normalizedExpectedRealPathURI, $normalizedRealPathURI);
unlink($tempFolder . '/test.xlsx');
}