Example #1
0
 public function test_chdir()
 {
     try {
         $shell = new Shell();
         $dir = $shell->mktempdir();
         $this->assertTrue(file_exists($dir), 'Temp dir was not created');
         $success = $shell->chdir($dir);
         $this->assertTrue($success, "Could not chdir {$dir}");
         $non_existent_dir = "/a/non/existent/{$dir}";
         // @ to prevent E_WARNING from being thrown
         $failure = @$shell->chdir($non_existent_dir);
         $this->assertFalse($failure, "chdir to {$non_existent_dir} should have failed");
         @rmdir($dir);
         // Clean up
     } catch (\Exception $e) {
         if ($dir) {
             @rmdir($dir);
             // Clean up
         }
         throw $e;
     }
 }