dropbox.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Robin Appelman <icewind@owncloud.com>
  7. * @author Vincent Petry <pvince81@owncloud.com>
  8. *
  9. * @copyright Copyright (c) 2015, ownCloud, Inc.
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace Test\Files\Storage;
  26. class Dropbox extends Storage {
  27. private $config;
  28. protected function setUp() {
  29. parent::setUp();
  30. $id = $this->getUniqueID();
  31. $this->config = include('files_external/tests/config.php');
  32. if ( ! is_array($this->config) or ! isset($this->config['dropbox']) or ! $this->config['dropbox']['run']) {
  33. $this->markTestSkipped('Dropbox backend not configured');
  34. }
  35. $this->config['dropbox']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
  36. $this->instance = new \OC\Files\Storage\Dropbox($this->config['dropbox']);
  37. }
  38. protected function tearDown() {
  39. if ($this->instance) {
  40. $this->instance->unlink('/');
  41. }
  42. parent::tearDown();
  43. }
  44. public function directoryProvider() {
  45. // doesn't support leading/trailing spaces
  46. return array(array('folder'));
  47. }
  48. public function testDropboxTouchReturnValue() {
  49. $this->assertFalse($this->instance->file_exists('foo'));
  50. // true because succeeded
  51. $this->assertTrue($this->instance->touch('foo'));
  52. $this->assertTrue($this->instance->file_exists('foo'));
  53. // false because not supported
  54. $this->assertFalse($this->instance->touch('foo'));
  55. }
  56. }