DropboxTest.php 2.3 KB

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