Fix "Cannot open file" issue with XMLReader::open on Windows
This occurred when using relative paths. Using realpath() solves this issue.
This commit is contained in:
1 parent
45980195cd
commit
01cc8b3da0
5 files changed
+111
-13
No files matched your search
@@ -163,4 +163,39 @@ class XMLReaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals($expectedResult, $isZipStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function dataProviderForTestConvertURIToUseRealPath()
|
||||
{
|
||||
$tempFolder = realpath(sys_get_temp_dir());
|
||||
|
||||
return [
|
||||
['/../../../' . $tempFolder . '/test.xlsx', $tempFolder . '/test.xlsx'],
|
||||
[$tempFolder . '/test.xlsx', $tempFolder . '/test.xlsx'],
|
||||
['zip://' . $tempFolder . '/test.xlsx#test.xml', 'zip://' . $tempFolder . '/test.xlsx#test.xml'],
|
||||
['zip:///../../../' . $tempFolder . '/test.xlsx#test.xml', 'zip://' . $tempFolder . '/test.xlsx#test.xml'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataProviderForTestConvertURIToUseRealPath
|
||||
*
|
||||
* @param string $URI
|
||||
* @param string $expectedConvertedURI
|
||||
* @return void
|
||||
*/
|
||||
public function testConvertURIToUseRealPath($URI, $expectedConvertedURI)
|
||||
{
|
||||
$tempFolder = sys_get_temp_dir();
|
||||
touch($tempFolder . '/test.xlsx');
|
||||
|
||||
$xmlReader = new XMLReader();
|
||||
$convertedURI = \ReflectionHelper::callMethodOnObject($xmlReader, 'convertURIToUseRealPath', $URI);
|
||||
|
||||
$this->assertEquals($expectedConvertedURI, $convertedURI);
|
||||
|
||||
unlink($tempFolder . '/test.xlsx');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user