protected function setUp()
 {
     parent::setUp();
     $this->user = $this->createAdmin();
     $this->user->login('test');
     $this->page = $this->site->children()->create('test', 'test');
     f::copy($this->roots->dummy . DS . 'images' . DS . 'forrest.jpg', $this->page->root() . DS . '1.jpg');
     f::copy($this->roots->dummy . DS . 'images' . DS . 'forrest.jpg', $this->page->root() . DS . '2.jpg');
 }
Пример #2
0
 /**
  * Copies the file to a new location
  *
  * @param string $to
  * @return boolean
  */
 public function copy($to)
 {
     return f::copy($this->root, $to);
 }
Пример #3
0
 public function testCopy()
 {
     $this->assertTrue(f::copy(TEST_ROOT_TMP . DS . 'moved.txt', TEST_ROOT_TMP . DS . 'copied.txt'));
 }
Пример #4
0
 public function attach($file, $filename = null)
 {
     // if the item has not been stored yet
     // throw an exception
     if (!$this->exists()) {
         throw new Exception('Unstored item');
     }
     // filename fallback
     if (is_null($filename)) {
         $filename = basename($file);
     }
     // sanitize the filename
     $filename = f::safeName($filename);
     // the item.yaml cannot be overwritten
     if ($filename == 'item.yaml') {
         throw new Exception('item.yaml is a reserved filename');
     }
     // files cannot be overwritten
     if (file_exists($this->root() . DS . $filename)) {
         throw new Exception('The file exists and cannot be overwritten');
     }
     // attach a remote url
     if (v::url($file)) {
         $response = remote::get($file);
         if ($response->code() < 400) {
             if (!f::write($this->root() . DS . $filename, $response->content())) {
                 throw new Exception('The file could not be saved');
             }
         } else {
             throw new Exception('The file could not be fetched');
         }
     } else {
         if (file_exists($file)) {
             if (!f::copy($file, $this->root() . DS . $filename)) {
                 throw new Exception('The file could not be copied');
             }
         }
     }
 }
Пример #5
0
 protected function copy()
 {
     // copy the controller template to the controller directory
     f::copy($this->template(), $this->file());
 }