smb.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. * @author Morris Jobke <hey@morrisjobke.de>
  5. * @author Robin Appelman <icewind@owncloud.com>
  6. * @author Thomas Müller <thomas.mueller@tmit.eu>
  7. * @author Vincent Petry <pvince81@owncloud.com>
  8. *
  9. * @copyright Copyright (c) 2016, 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. /**
  27. * Class SMB
  28. *
  29. * @group DB
  30. *
  31. * @package Test\Files\Storage
  32. */
  33. class SMB extends Storage {
  34. protected function setUp() {
  35. parent::setUp();
  36. $id = $this->getUniqueID();
  37. $config = include('files_external/tests/config.smb.php');
  38. if (!is_array($config) or !$config['run']) {
  39. $this->markTestSkipped('Samba backend not configured');
  40. }
  41. if (substr($config['root'], -1, 1) != '/') {
  42. $config['root'] .= '/';
  43. }
  44. $config['root'] .= $id; //make sure we have an new empty folder to work in
  45. $this->instance = new \OC\Files\Storage\SMB($config);
  46. $this->instance->mkdir('/');
  47. }
  48. protected function tearDown() {
  49. if ($this->instance) {
  50. $this->instance->rmdir('');
  51. }
  52. parent::tearDown();
  53. }
  54. public function directoryProvider() {
  55. // doesn't support leading/trailing spaces
  56. return array(array('folder'));
  57. }
  58. public function testRenameWithSpaces() {
  59. $this->instance->mkdir('with spaces');
  60. $result = $this->instance->rename('with spaces', 'foo bar');
  61. $this->assertTrue($result);
  62. $this->assertTrue($this->instance->is_dir('foo bar'));
  63. }
  64. public function testStorageId() {
  65. $this->instance = new \OC\Files\Storage\SMB([
  66. 'host' => 'testhost',
  67. 'user' => 'testuser',
  68. 'password' => 'somepass',
  69. 'share' => 'someshare',
  70. 'root' => 'someroot',
  71. ]);
  72. $this->assertEquals('smb::testuser@testhost//someshare//someroot/', $this->instance->getId());
  73. $this->instance = null;
  74. }
  75. }