protected function resetDirectory($path)
 {
     if (file_exists($path)) {
         $cleaner = new Stagehand_DirectoryCleaner();
         $cleaner->clean($path);
     } else {
         mkdir($path);
     }
 }
 /**
  * @test
  */
 public function cleanADirectoryNotRecursively()
 {
     $this->assertFileExists($this->directory . '/example.txt');
     $this->assertFileExists($this->directory . '/first');
     $this->assertFileExists($this->directory . '/first/second');
     $this->assertFileExists($this->directory . '/first/foo.txt');
     $this->assertFileExists($this->directory . '/first/bar.txt');
     $this->assertFileExists($this->directory . '/first/second/baz.txt');
     $cleaner = new Stagehand_DirectoryCleaner();
     $cleaner->clean($this->directory, false);
     $this->assertFileNotExists($this->directory . '/example.txt');
     $this->assertFileExists($this->directory . '/first');
     $this->assertFileExists($this->directory . '/first/second');
     $this->assertFileExists($this->directory . '/first/foo.txt');
     $this->assertFileExists($this->directory . '/first/bar.txt');
     $this->assertFileExists($this->directory . '/first/second/baz.txt');
 }
 /**
  * @throws Stagehand_DirectorySnap_Exception Snap a directory first.
  */
 public function restore()
 {
     if (!$this->snappedPath) {
         throw new Stagehand_DirectorySnap_Exception('Snap a directory first.');
     }
     $cleaner = new Stagehand_DirectoryCleaner();
     $cleaner->clean($this->snappedPath);
     if ($this->useTemporary) {
         $scanner = new Stagehand_DirectoryScanner(array($this, 'restoreOrigin'), false);
         $scanner->scan($this->temporaryPath);
     } else {
         foreach ($this->elements as $element) {
             $element->push($this->snappedPath);
         }
     }
 }