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

+15 -2
View File
@@ -7,8 +7,8 @@ namespace Box\Spout;
*
* @package Box\Spout
*/
trait TestUsingResource {
trait TestUsingResource
{
/** @var string Path to the test resources folder */
private $resourcesPath = 'tests/resources';
@@ -70,6 +70,11 @@ trait TestUsingResource {
*/
protected function createUnwritableFolderIfNeeded()
{
// On Windows, chmod() or the mkdir's mode is ignored
if ($this->isWindows()) {
$this->markTestSkipped('Skipping because Windows cannot create read-only folders through PHP');
}
if (!file_exists($this->generatedUnwritableResourcesPath)) {
// Make sure generated folder exists first
if (!file_exists($this->generatedResourcesPath)) {
@@ -80,4 +85,12 @@ trait TestUsingResource {
mkdir($this->generatedUnwritableResourcesPath, 0444, true);
}
}
/**
* @return bool Whether the OS on which PHP is installed is Windows
*/
protected function isWindows()
{
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}
}