Changeset View
Changeset View
Standalone View
Standalone View
src/filesystem/__tests__/FilesystemTestCase.php
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | try { | ||||
$caught = $ex; | $caught = $ex; | ||||
} | } | ||||
$this->assertTrue($caught instanceof Exception); | $this->assertTrue($caught instanceof Exception); | ||||
} | } | ||||
public function testWalkToRoot() { | public function testWalkToRoot() { | ||||
$test_cases = array( | $test_cases = array( | ||||
array( | array( | ||||
dirname(__FILE__).'/data/include_dir.txt/subdir.txt/test', | __DIR__.'/data/include_dir.txt/subdir.txt/test', | ||||
dirname(__FILE__), | __DIR__, | ||||
array( | array( | ||||
dirname(__FILE__).'/data/include_dir.txt/subdir.txt/test', | __DIR__.'/data/include_dir.txt/subdir.txt/test', | ||||
dirname(__FILE__).'/data/include_dir.txt/subdir.txt', | __DIR__.'/data/include_dir.txt/subdir.txt', | ||||
dirname(__FILE__).'/data/include_dir.txt', | __DIR__.'/data/include_dir.txt', | ||||
dirname(__FILE__).'/data', | __DIR__.'/data', | ||||
dirname(__FILE__), | __DIR__, | ||||
), | ), | ||||
), | ), | ||||
array( | array( | ||||
dirname(__FILE__).'/data/include_dir.txt/subdir.txt', | __DIR__.'/data/include_dir.txt/subdir.txt', | ||||
dirname(__FILE__), | __DIR__, | ||||
array( | array( | ||||
dirname(__FILE__).'/data/include_dir.txt/subdir.txt', | __DIR__.'/data/include_dir.txt/subdir.txt', | ||||
dirname(__FILE__).'/data/include_dir.txt', | __DIR__.'/data/include_dir.txt', | ||||
dirname(__FILE__).'/data', | __DIR__.'/data', | ||||
dirname(__FILE__), | __DIR__, | ||||
), | ), | ||||
), | ), | ||||
'root and path are identical' => array( | 'root and path are identical' => array( | ||||
dirname(__FILE__), | __DIR__, | ||||
dirname(__FILE__), | __DIR__, | ||||
array( | array( | ||||
dirname(__FILE__), | __DIR__, | ||||
), | ), | ||||
), | ), | ||||
'root is not an ancestor of path' => array( | 'root is not an ancestor of path' => array( | ||||
dirname(__FILE__), | __DIR__, | ||||
dirname(__FILE__).'/data/include_dir.txt/subdir.txt', | __DIR__.'/data/include_dir.txt/subdir.txt', | ||||
array(), | array(), | ||||
), | ), | ||||
'fictional paths work' => array( | 'fictional paths work' => array( | ||||
'/x/y/z', | '/x/y/z', | ||||
'/', | '/', | ||||
array( | array( | ||||
'/x/y/z', | '/x/y/z', | ||||
Show All 19 Lines | foreach ($test_cases as $test_case) { | ||||
Filesystem::walkToRoot($path, $root)); | Filesystem::walkToRoot($path, $root)); | ||||
} | } | ||||
} | } | ||||
public function testisDescendant() { | public function testisDescendant() { | ||||
$test_cases = array( | $test_cases = array( | ||||
array( | array( | ||||
__FILE__, | __FILE__, | ||||
dirname(__FILE__), | __DIR__, | ||||
true, | true, | ||||
), | ), | ||||
array( | array( | ||||
dirname(__FILE__), | __DIR__, | ||||
dirname(dirname(__FILE__)), | dirname(__DIR__), | ||||
true, | true, | ||||
), | ), | ||||
array( | array( | ||||
dirname(__FILE__), | __DIR__, | ||||
phutil_get_library_root_for_path(__FILE__), | phutil_get_library_root_for_path(__FILE__), | ||||
true, | true, | ||||
), | ), | ||||
array( | array( | ||||
dirname(dirname(__FILE__)), | dirname(__DIR__), | ||||
dirname(__FILE__), | __DIR__, | ||||
false, | false, | ||||
), | ), | ||||
array( | array( | ||||
dirname(__FILE__).'/quack', | __DIR__.'/quack', | ||||
dirname(__FILE__), | __DIR__, | ||||
false, | false, | ||||
), | ), | ||||
); | ); | ||||
foreach ($test_cases as $test_case) { | foreach ($test_cases as $test_case) { | ||||
list($path, $root, $expected) = $test_case; | list($path, $root, $expected) = $test_case; | ||||
$this->assertEqual( | $this->assertEqual( | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0