示例#1
0
 public function doSync()
 {
     $ui = new UserInterface();
     $statusCallback = function ($status) {
         echo $status->Timestamp . " -- ";
         if ($status->isError()) {
             echo "ERROR: ";
         }
         if ($status->isWarning()) {
             echo "WARNING: ";
         }
         if ($status->isRawOutput()) {
             echo "\n================\n";
         }
         echo $status->Message . "\n";
         if ($status->isRawOutput()) {
             echo "================\n";
         }
     };
     $ui->say("o  Syncing upload folders from {$this->sourceName} to {$this->destName}.");
     $folderSyncSuccess = $this->folderSync->sync($statusCallback);
     $ui->say("o  Syncing database from {$this->sourceName} to {$this->destName}.");
     $databaseSyncSuccess = $this->databaseSync->sync($statusCallback);
     if (!$folderSyncSuccess || !$databaseSyncSuccess) {
         $ui->say("o  Completed with errors.");
     } else {
         $ui->say("o  Completed successfully!");
     }
 }
 /**
  * Do a sync, but don't delete any files.
  */
 public function testNoDelete()
 {
     $source = $this->folders['source'];
     $dest = $this->folders['dest'];
     $folderSync = new FolderSync($source, $dest, ['delete' => false]);
     $success = $folderSync->sync();
     $this->assertTrue($success);
     // all of the source, dest, and shared files should be in the destination
     $sourceFilesMerged = array_merge($this->sourceFiles, $this->sharedFiles, $this->destFiles);
     foreach ($sourceFilesMerged as $filename) {
         $filePath = "{$dest}/{$filename}";
         $this->assertFileExists($filePath);
     }
 }