/**
  * Tests kFileTransferMgr->fileSize()
  * 
  * @param string $server Server's hostname or IP address
  * @param string $user User's name
  * @param string $pass Password
  * @param int $port Server's listening port
  * @param bool $ftp_passive_mode Used for FTP only
  * @param string $publicKeyFile
  * @param string $privateKeyFile
  * @param string $passPhrase
  * @param string $remote_path
  * @param string $file
  * @param int $expectedSize
  * @param int $exceptionCode the expected exception code
  * @dataProvider provideData
  */
 public function testFileSize($server, $user, $pass, $port, $ftp_passive_mode, $publicKeyFile, $privateKeyFile, $passPhrase, $remote_path, $file, $expectedSize, $exceptionCode = null)
 {
     try {
         if (strlen(trim($publicKeyFile))) {
             $this->kFileTransferMgr->loginPubKey($server, $user, $publicKeyFile, $privateKeyFile, $passPhrase, $port);
         } else {
             $this->kFileTransferMgr->login($server, $user, $pass, $port, $ftp_passive_mode);
         }
         $actualSize = $this->kFileTransferMgr->fileSize("{$remote_path}/{$file}");
         $this->assertEquals($expectedSize, $actualSize, "Wrong file size [{$remote_path}/{$file}]");
     } catch (kFileTransferMgrException $te) {
         $this->assertEquals($exceptionCode, $te->getCode(), "Wrong transfer exception code [" . $te->getMessage() . "]");
         return;
     } catch (Exception $e) {
         $this->assertEquals($exceptionCode, $e->getCode(), "Wrong exception code [" . $e->getMessage() . "]");
         return;
     }
     if ($exceptionCode) {
         $this->fail("Expected exception code [{$exceptionCode}]");
     }
 }
Пример #2
0
 /**
  * Login using fileTransferMgr according to the available credentials
  * @param kFileTransferMgr $fileTransferMgr
  */
 public function loginByCredentialsType(kFileTransferMgr $fileTransferMgr)
 {
     return $fileTransferMgr->login(null, null, null);
 }
Пример #3
0
 public function loginByCredentialsType(kFileTransferMgr $fileTransferMgr)
 {
     return $fileTransferMgr->login($this->getFtpHost(), $this->getFtpUsername(), $this->getFtpPassword(), $this->getFtpPort());
 }
Пример #4
0
 public function loginByCredentialsType(kFileTransferMgr $fileTransferMgr)
 {
     if ($this->getSshPrivateKey() || $this->getSshPublicKey()) {
         $privKeyFile = $this->getTempFileWithContent($this->getSshPrivateKey(), 'privateKey');
         $pubKeyFile = $this->getTempFileWithContent($this->getSshPublicKey(), 'publicKey');
         return $fileTransferMgr->loginPubKey($this->getSshHost(), $this->getSshUsername(), $pubKeyFile, $privKeyFile, $this->getSshPassPhrase(), $this->getSshPort());
     } else {
         return $fileTransferMgr->login($this->getSshHost(), $this->getSshUsername(), $this->getSshPassword(), $this->getSshPort());
     }
 }