示例#1
0
 public function testFtpDirectories()
 {
     $list = [__DIR__ . '/new' => '/test', __DIR__ . '/update' => '/test', __DIR__ . '/delete' => '/test'];
     $ftp = new GlSyncFtp(FTP_SERVER_HOST, FTP_SERVER_USER, FTP_SERVER_PASSWORD);
     $nbr = 0;
     $nbrnew = 0;
     $ftp->syncDirectories($list, function ($src, $dst) {
     }, function ($op, $path) use(&$nbr, &$nbrnew) {
         switch ($op) {
             case GlSyncFtp::CREATE_DIR:
                 switch ($nbr) {
                     case 0:
                         $this->assertEquals("/test/dir1", $path);
                         break;
                     default:
                 }
                 break;
             case GlSyncFtp::NEW_FILE:
                 switch ($nbrnew) {
                     case 0:
                         $this->assertEquals("/test/dir1/test1.txt", $path);
                         break;
                     case 1:
                         $this->assertEquals("/test/test2.txt", $path);
                         break;
                     default:
                 }
                 $nbrnew++;
                 break;
             default:
         }
         $nbr++;
     });
     $files = [];
     $dirs = [];
     $ftp->getAllFiles('/test', $files, $dirs);
     $this->assertCount(0, $files);
     $this->assertCount(0, $dirs);
 }
示例#2
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use GlSyncFtp\GlSyncFtp;
$ftp = new GlSyncFtp(FTP_SERVER_HOST, FTP_SERVER_USER, FTP_SERVER_PASSWORD);
$ftp->syncDirectory(__DIR__ . '/delete', '/test');
$ftp->disconnect();