Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (2)
test:php74:
image: bokeh_php74_with_chrome
image: bokeh-php-7.4-webmaster
script:
- bash build.sh
except:
......@@ -9,7 +9,7 @@ test:php74:
test:php81:
image: bokeh_php81
image: bokeh-php-8.1-webmaster
script:
- bash build.sh
except:
......
......@@ -82,13 +82,13 @@ class Storm_FileSystem_Disk extends Storm_FileSystem_Abstract {
public function directoryNamesAt($path) {
if (!file_exists($path))
if (!file_exists($path) || !is_readable($path) )
return [];
$dirs = [];
foreach (new DirectoryIterator($path) as $entry) {
if ($entry->isDir() && !$entry->isDot())
$dirs[$entry->getFilename()] = $entry->getFilename();
if ($entry->isDir() && $entry->isReadable() && !$entry->isDot())
$dirs[$entry->getFilename()] = $entry->getFilename();
}
asort($dirs);
......@@ -97,12 +97,13 @@ class Storm_FileSystem_Disk extends Storm_FileSystem_Abstract {
public function fileNamesAt($path) {
if (!file_exists($path))
if (!file_exists($path)
|| !is_readable($path))
return [];
$files = [];
foreach (new DirectoryIterator($path) as $entry) {
if ($entry->isFile() && !$entry->isDot())
if ($entry->isFile() && $entry->isReadable() && !$entry->isDot())
$files[$entry->getFilename()] = $entry->getFilename();
}
......
<?php
/**
* Copyright (c) 2012-2022, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
abstract class Storm_FileSystem_DiskTestCase extends PHPUnit_Framework_TestCase {
protected Storm_FileSystem_Disk $_fs;
public function setUp() {
parent::setUp();
$this->_fs = new Storm_FileSystem_Disk;
}
}
class Storm_FileSystem_DiskBasicTest extends Storm_FileSystem_DiskTestCase {
protected $_directory,$_subdirectory;
public function setUp() {
parent::setUp();
$this->_directory = uniqid();
$this->_subdirectory = uniqid();
mkdir($this->_directory);
mkdir($this->_directory.'/'.$this->_subdirectory);
$file = fopen( $this->_directory.'/testfile','c');
fclose($file);
}
public function tearDown() {
chmod($this->_directory.'/testfile',0700);
unlink($this->_directory.'/testfile');
chmod($this->_directory.'/'.$this->_subdirectory,0700);
rmdir($this->_directory.'/'.$this->_subdirectory);
rmdir($this->_directory);
parent::tearDown();
}
/** @test */
public function directoryNamesAtForTempShouldContainsReadableSubDirectory() {
$this->assertEquals([$this->_subdirectory => $this->_subdirectory],
$this->_fs->directoryNamesAt($this->_directory));
}
/** @test */
public function fileNamesAtShouldBetestfile() {
$this->assertEquals(['testfile' => 'testfile'],
$this->_fs->fileNamesAt($this->_directory));
}
/** @test */
public function directoryNamesTmpWithNoReadableDirectoryAtShouldBeEmpty() {
if (FALSE === chmod($this->_directory.'/'.$this->_subdirectory,0000))
$this->markTestSkipped();
$this->assertEmpty($this->_fs->directoryNamesAt($this->_directory));
}
/** @test */
public function directoryNamesAtForMytestDirectoryNotReadableShouldBeEmpty() {
if (FALSE === chmod($this->_directory.'/'.$this->_subdirectory,0000))
$this->markTestSkipped();
$this->assertEmpty($this->_fs->directoryNamesAt($this->_directory.'/'.$this->_subdirectory));
}
/** @test */
public function fileNamesAtTempForTmpDirectoryShouldBeEmpty() {
chmod( $this->_directory.'/testfile',0000);
$this->assertEmpty($this->_fs->fileNamesAt($this->_directory));
}
/** @test */
public function fileNamesAtForTestfileShouldBeEmpty() {
chmod( $this->_directory.'/testfile',0000);
$this->assertEmpty($this->_fs->fileNamesAt($this->_directory.'/testfile'));
}
}
\ No newline at end of file