function test_upload_nofile() { $this->setExpectedException('CloudFilesException'); $retval = CloudFiles::upload(); $this->assertFalse($retval); $this->assertEqual('File path and container required.', CloudFiles::$errors[0]); }
function upload() { $directory = $this->getNextParam(null, 'path'); $container = $this->getNextParam(null, 'container'); if (empty($directory) || empty($container)) { $this->errorAndExit('Directory and Container required'); } $Folder = new Folder($directory); if ($this->params['recursive']) { $files = $Folder->findRecursive(); } else { $single_files = $Folder->find(); $files = array(); foreach ($single_files as $file) { $files[] = $Folder->pwd() . DS . $file; } } $this->ProgressBar->start(count($files)); foreach ($files as $file) { CloudFiles::upload($file, $container); $this->ProgressBar->next(); } $this->out(); $this->out("Finished."); }