PageRenderTime 54ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/apps/files_external/tests/ftp.php

https://github.com/sezuan/core
PHP | 52 lines | 38 code | 8 blank | 6 comment | 2 complexity | 115d575316859135f6bf74e9f11fb110 MD5 | raw file
Possible License(s): AGPL-3.0, AGPL-1.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test\Files\Storage;
  9. class FTP extends Storage {
  10. private $config;
  11. public function setUp() {
  12. $id = uniqid();
  13. $this->config = include('files_external/tests/config.php');
  14. if ( ! is_array($this->config) or ! isset($this->config['ftp']) or ! $this->config['ftp']['run']) {
  15. $this->markTestSkipped('FTP backend not configured');
  16. }
  17. $this->config['ftp']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
  18. $this->instance = new \OC\Files\Storage\FTP($this->config['ftp']);
  19. $this->instance->mkdir('/');
  20. }
  21. public function tearDown() {
  22. if ($this->instance) {
  23. \OCP\Files::rmdirr($this->instance->constructUrl(''));
  24. }
  25. }
  26. public function testConstructUrl(){
  27. $config = array ( 'host' => 'localhost',
  28. 'user' => 'ftp',
  29. 'password' => 'ftp',
  30. 'root' => '/',
  31. 'secure' => false );
  32. $instance = new OC_Filestorage_FTP($config);
  33. $this->assertEquals('ftp://ftp:ftp@localhost/', $instance->constructUrl(''));
  34. $config['secure'] = true;
  35. $instance = new OC_Filestorage_FTP($config);
  36. $this->assertEquals('ftps://ftp:ftp@localhost/', $instance->constructUrl(''));
  37. $config['secure'] = 'false';
  38. $instance = new OC_Filestorage_FTP($config);
  39. $this->assertEquals('ftp://ftp:ftp@localhost/', $instance->constructUrl(''));
  40. $config['secure'] = 'true';
  41. $instance = new OC_Filestorage_FTP($config);
  42. $this->assertEquals('ftps://ftp:ftp@localhost/', $instance->constructUrl(''));
  43. }
  44. }