/** * Tests kFileTransferMgr->listDir() * * @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 array $list * @param int $exceptionCode the expected exception code * @dataProvider provideData */ public function testListDir($server, $user, $pass, $port, $ftp_passive_mode, $publicKeyFile, $privateKeyFile, $passPhrase, $remote_path, $list, $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); } $actualList = $this->kFileTransferMgr->listDir($remote_path); KalturaLog::debug("Actual List [" . print_r($actualList, true) . "]"); $this->assertEquals(count($list), count($actualList), 'Wrong list size'); foreach ($list as $value) { if (!in_array($value, $actualList)) { $this->fail("Missing file [{$value}]"); } } } 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}]"); } }
/** * @param KalturaDropFolder $folder * @return array of file names in the given $folder's path */ private function getPhysicalFileList(KalturaDropFolder $folder) { return $this->fileTransferMgr->listDir($folder->path); }