1
0

OwnCloudFunctionsTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files_External\Tests;
  8. use OCA\Files_External\Lib\Storage\OwnCloud;
  9. /**
  10. * Class OwnCloudFunctions
  11. *
  12. * @group DB
  13. *
  14. * @package OCA\Files_External\Tests
  15. */
  16. class OwnCloudFunctionsTest extends \Test\TestCase {
  17. public function configUrlProvider() {
  18. return [
  19. [
  20. [
  21. 'host' => 'testhost',
  22. 'root' => 'testroot',
  23. 'secure' => false
  24. ],
  25. 'http://testhost/remote.php/webdav/testroot/',
  26. ],
  27. [
  28. [
  29. 'host' => 'testhost',
  30. 'root' => 'testroot',
  31. 'secure' => true
  32. ],
  33. 'https://testhost/remote.php/webdav/testroot/',
  34. ],
  35. [
  36. [
  37. 'host' => 'http://testhost',
  38. 'root' => 'testroot',
  39. 'secure' => false
  40. ],
  41. 'http://testhost/remote.php/webdav/testroot/',
  42. ],
  43. [
  44. [
  45. 'host' => 'https://testhost',
  46. 'root' => 'testroot',
  47. 'secure' => false
  48. ],
  49. 'https://testhost/remote.php/webdav/testroot/',
  50. ],
  51. [
  52. [
  53. 'host' => 'https://testhost/testroot',
  54. 'root' => '',
  55. 'secure' => false
  56. ],
  57. 'https://testhost/testroot/remote.php/webdav/',
  58. ],
  59. [
  60. [
  61. 'host' => 'https://testhost/testroot',
  62. 'root' => 'subdir',
  63. 'secure' => false
  64. ],
  65. 'https://testhost/testroot/remote.php/webdav/subdir/',
  66. ],
  67. [
  68. [
  69. 'host' => 'http://testhost/testroot',
  70. 'root' => 'subdir',
  71. 'secure' => true
  72. ],
  73. 'http://testhost/testroot/remote.php/webdav/subdir/',
  74. ],
  75. [
  76. [
  77. 'host' => 'http://testhost/testroot/',
  78. 'root' => '/subdir',
  79. 'secure' => false
  80. ],
  81. 'http://testhost/testroot/remote.php/webdav/subdir/',
  82. ],
  83. ];
  84. }
  85. /**
  86. * @dataProvider configUrlProvider
  87. */
  88. public function testConfig($config, $expectedUri): void {
  89. $config['user'] = 'someuser';
  90. $config['password'] = 'somepassword';
  91. $instance = new OwnCloud($config);
  92. $this->assertEquals($expectedUri, $instance->createBaseUri());
  93. }
  94. }