mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-14 04:42:04 +02:00
[ticket/15253] Update tests
PHPBB3-15253
This commit is contained in:
parent
b1755d9dac
commit
45334eadb6
tests
filesystem
storage/adapter
@ -23,25 +23,23 @@ class phpbb_filesystem_helper_clean_path_test extends phpbb_test_case
|
||||
|
||||
public function clean_path_data()
|
||||
{
|
||||
return array(
|
||||
array('foo', 'foo'),
|
||||
array('foo/bar', 'foo/bar'),
|
||||
array('foo/bar/', 'foo/bar/'),
|
||||
array('foo/./bar', 'foo/bar'),
|
||||
array('foo/./././bar', 'foo/bar'),
|
||||
array('foo/bar/.', 'foo/bar'),
|
||||
array('./foo/bar', './foo/bar'),
|
||||
array('../foo/bar', '../foo/bar'),
|
||||
array('./../foo/bar', './../foo/bar'),
|
||||
array('././../foo/bar', './../foo/bar'),
|
||||
array('one/two/three', 'one/two/three'),
|
||||
array('one/two/../three', 'one/three'),
|
||||
array('one/../two/three', 'two/three'),
|
||||
array('one/two/..', 'one'),
|
||||
array('one/two/../', 'one/'),
|
||||
array('one/two/../three/../four', 'one/four'),
|
||||
array('one/two/three/../../four', 'one/four'),
|
||||
);
|
||||
yield ['foo', 'foo'];
|
||||
yield ['foo/bar', 'foo/bar'];
|
||||
yield ['foo/bar/', 'foo/bar/'];
|
||||
yield ['foo/./bar', 'foo/bar'];
|
||||
yield ['foo/./././bar', 'foo/bar'];
|
||||
yield ['foo/bar/.', 'foo/bar'];
|
||||
yield ['./foo/bar', './foo/bar'];
|
||||
yield ['../foo/bar', '../foo/bar'];
|
||||
yield ['./../foo/bar', './../foo/bar'];
|
||||
yield ['././../foo/bar', './../foo/bar'];
|
||||
yield ['one/two/three', 'one/two/three'];
|
||||
yield ['one/two/../three', 'one/three'];
|
||||
yield ['one/../two/three', 'two/three'];
|
||||
yield ['one/two/..', 'one'];
|
||||
yield ['one/two/../', 'one/'];
|
||||
yield ['one/two/../three/../four', 'one/four'];
|
||||
yield ['one/two/three/../../four', 'one/four'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use phpbb\filesystem\helper as filesystem_helper;
|
||||
use phpbb\filesystem\helper as filesystem_helper;
|
||||
|
||||
class phpbb_filesystem_helper_is_absolute_test extends phpbb_test_case
|
||||
{
|
||||
@ -23,37 +23,35 @@ class phpbb_filesystem_helper_is_absolute_test extends phpbb_test_case
|
||||
|
||||
static public function is_absolute_data()
|
||||
{
|
||||
return array(
|
||||
// Empty
|
||||
array('', false),
|
||||
// Empty
|
||||
yield ['', false];
|
||||
|
||||
// Absolute unix style
|
||||
array('/etc/phpbb', true),
|
||||
// Unix does not support \ so that is not an absolute path
|
||||
array('\etc\phpbb', false),
|
||||
// Absolute unix style
|
||||
yield ['/etc/phpbb', true];
|
||||
// Unix does not support \ so that is not an absolute path
|
||||
yield ['\etc\phpbb', false];
|
||||
|
||||
// Absolute windows style
|
||||
array('c:\windows', true),
|
||||
array('C:\Windows', true),
|
||||
array('c:/windows', true),
|
||||
array('C:/Windows', true),
|
||||
// Absolute windows style
|
||||
yield ['c:\windows', true];
|
||||
yield ['C:\Windows', true];
|
||||
yield ['c:/windows', true];
|
||||
yield ['C:/Windows', true];
|
||||
|
||||
// Executable
|
||||
array('etc/phpbb', false),
|
||||
array('explorer.exe', false),
|
||||
// Executable
|
||||
yield ['etc/phpbb', false];
|
||||
yield ['explorer.exe', false];
|
||||
|
||||
// Relative subdir
|
||||
array('Windows\System32', false),
|
||||
array('Windows\System32\explorer.exe', false),
|
||||
array('Windows/System32', false),
|
||||
array('Windows/System32/explorer.exe', false),
|
||||
// Relative subdir
|
||||
yield ['Windows\System32', false];
|
||||
yield ['Windows\System32\explorer.exe', false];
|
||||
yield ['Windows/System32', false];
|
||||
yield ['Windows/System32/explorer.exe', false];
|
||||
|
||||
// Relative updir
|
||||
array('..\Windows\System32', false),
|
||||
array('..\Windows\System32\explorer.exe', false),
|
||||
array('../Windows/System32', false),
|
||||
array('../Windows/System32/explorer.exe', false),
|
||||
);
|
||||
// Relative updir
|
||||
yield ['..\Windows\System32', false];
|
||||
yield ['..\Windows\System32\explorer.exe', false];
|
||||
yield ['../Windows/System32', false];
|
||||
yield ['../Windows/System32/explorer.exe', false];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use phpbb\filesystem\helper as filesystem_helper;
|
||||
use phpbb\filesystem\helper as filesystem_helper;
|
||||
|
||||
class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
|
||||
{
|
||||
@ -21,7 +21,7 @@ class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$filesystem_helper_phpbb_own_realpath = new ReflectionMethod('filesystem_helper', 'phpbb_own_realpath');
|
||||
self::$filesystem_helper_phpbb_own_realpath = new ReflectionMethod('\phpbb\filesystem\helper', 'phpbb_own_realpath');
|
||||
self::$filesystem_helper_phpbb_own_realpath->setAccessible(true);
|
||||
}
|
||||
|
||||
@ -32,16 +32,14 @@ class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
|
||||
|
||||
public function realpath_resolve_absolute_without_symlinks_data()
|
||||
{
|
||||
return array(
|
||||
// Constant data
|
||||
array(__DIR__, __DIR__),
|
||||
array(__DIR__ . '/../filesystem/../filesystem', __DIR__),
|
||||
array(__DIR__ . '/././', __DIR__),
|
||||
array(__DIR__ . '/non_existent', false),
|
||||
// Constant data
|
||||
yield [__DIR__, __DIR__];
|
||||
yield [__DIR__ . '/../filesystem/../filesystem', __DIR__];
|
||||
yield [__DIR__ . '/././', __DIR__];
|
||||
yield [__DIR__ . '/non_existent', false];
|
||||
|
||||
array(__FILE__, __FILE__),
|
||||
array(__FILE__ . '../', false),
|
||||
);
|
||||
yield [__FILE__, __FILE__];
|
||||
yield [__FILE__ . '../', false];
|
||||
}
|
||||
|
||||
public function realpath_resolve_relative_without_symlinks_data()
|
||||
@ -53,13 +51,11 @@ class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
|
||||
|
||||
$relative_path = filesystem_helper::make_path_relative(__DIR__, getcwd());
|
||||
|
||||
return array(
|
||||
array($relative_path, __DIR__),
|
||||
array($relative_path . '../filesystem/../filesystem', __DIR__),
|
||||
array($relative_path . '././', __DIR__),
|
||||
yield [$relative_path, __DIR__];
|
||||
yield [$relative_path . '../filesystem/../filesystem', __DIR__];
|
||||
yield [$relative_path . '././', __DIR__];
|
||||
|
||||
array($relative_path . 'helper_realpath_test.php', __FILE__),
|
||||
);
|
||||
yield [$relative_path . 'helper_realpath_test.php', __FILE__];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,14 @@
|
||||
$this->adapter = new \phpbb\storage\adapter\local($config, $filesystem, $phpbb_root_path, $path_key);
|
||||
}
|
||||
|
||||
public function data_test_exists()
|
||||
{
|
||||
yield ['README.md', true];
|
||||
yield ['nonexistent_file.php', false];
|
||||
yield ['phpBB/phpbb', true];
|
||||
yield ['nonexistent/folder', false];
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$this->adapter = null;
|
||||
@ -48,24 +56,24 @@
|
||||
unlink('file.txt');
|
||||
}
|
||||
|
||||
public function test_exists()
|
||||
/**
|
||||
* @dataProvider data_test_exists
|
||||
*/
|
||||
public function test_exists($path, $expected)
|
||||
{
|
||||
// Exists with files
|
||||
$this->assertTrue($this->adapter->exists('README.md'));
|
||||
$this->assertFalse($this->adapter->exists('nonexistent_file.php'));
|
||||
// exists with directory
|
||||
$this->assertTrue($this->adapter->exists('phpBB'));
|
||||
$this->assertFalse($this->adapter->exists('nonexistet_folder'));
|
||||
$this->assertSame($expected, $this->adapter->exists($path));
|
||||
}
|
||||
|
||||
public function test_delete()
|
||||
public function test_delete_file()
|
||||
{
|
||||
// Delete with files
|
||||
file_put_contents('file.txt', '');
|
||||
$this->assertTrue(file_exists('file.txt'));
|
||||
$this->adapter->delete('file.txt');
|
||||
$this->assertFalse(file_exists('file.txt'));
|
||||
// Delete with directories
|
||||
}
|
||||
|
||||
public function test_delete_folder()
|
||||
{
|
||||
mkdir('path/to/dir', 0777, true);
|
||||
$this->assertTrue(file_exists('path/to/dir'));
|
||||
$this->adapter->delete('path');
|
||||
|
Loading…
x
Reference in New Issue
Block a user