OwnCloudFunctionsTest.php 2.0 KB

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