Example #1
0
 public function testFileCreateOpenAndDelete()
 {
     if (!$this->testWritable()) {
         return;
     }
     try {
         $file = File::create($this->getTestFile());
     } catch (Exception $e) {
         $this->assert(false, "The file could not be created with message: {$e->getMessage()}.");
         return;
     }
     try {
         $file = File::open($file->getPathname());
     } catch (Exception $e) {
         $this->assert(false, "The file could not be opened with message: {$e->getMessage()}.");
         return;
     }
     try {
         $file->delete();
     } catch (Exception $e) {
         $this->assert(false, "The file {$file->getPathname()} could not be deleted with message: {$e->getMessage()}.");
     }
 }
Example #2
0
 public function searchAndReplace($regex, $replacement)
 {
     $items = array();
     foreach ($this->searchIn($regex)->getItems() as $file) {
         $count = File::open($file)->searchAndReplace($regex, $replacement);
         if ($count) {
             $items[] = $file;
         }
     }
     return $items;
 }