public function test_navigationAndLs() { $fs = new FileSystem(__DIR__); $thisFile = basename(__FILE__); $list = $fs->ls(); $this->assertTrue(isset($thisFile, $list)); $this->assertTrue(is_array($list[$thisFile])); $this->assertEquals($list[$thisFile]['type'], 'file'); $this->assertTrue(isset($list['files'])); $this->assertEquals($list['files']['type'], 'dir'); $this->assertTrue((bool) $fs->cd('files')); $this->assertEquals($fs->cwd, '/files'); $this->assertEquals($fs->realcwd, dirname(__FILE__) . '/files'); $this->assertTrue($fs->cdup()); $this->assertEquals($fs->cwd, '/'); $this->assertEquals(preg_replace('~/$~', '', $fs->realcwd), dirname(__FILE__)); //this should fail, because it's higher than allowed. $this->assertFalse($fs->cdup()); $this->assertEquals($fs->cwd, '/'); $this->assertEquals(preg_replace('~/$~', '', $fs->realcwd), dirname(__FILE__)); $this->assertTrue((bool) $fs->cd('/')); $this->assertEquals($fs->cwd, '/'); $this->assertEquals(preg_replace('~/$~', '', $fs->realcwd), dirname(__FILE__)); //make sure we can still find just this file. $fileInfo = $fs->ls(basename(__FILE__)); $this->assertTrue(is_array($fileInfo)); $this->assertEquals(count($fileInfo), 1, "too many files in the array..."); $this->assertTrue(isset($fileInfo[basename(__FILE__)])); $this->assertTrue(isset($fileInfo[basename(__FILE__)]['type']), "malformed array, should ONLY contain info about this file::: " . ToolBox::debug_print($fileInfo, 0)); }