OwnCloudFunctionsTest.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin McCorkell <robin@mccorkell.me.uk>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. * @author Vincent Petry <pvince81@owncloud.com>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCA\Files_External\Tests;
  27. /**
  28. * Class OwnCloudFunctions
  29. *
  30. * @group DB
  31. *
  32. * @package OCA\Files_External\Tests
  33. */
  34. class OwnCloudFunctionsTest extends \Test\TestCase {
  35. function configUrlProvider() {
  36. return array(
  37. array(
  38. array(
  39. 'host' => 'testhost',
  40. 'root' => 'testroot',
  41. 'secure' => false
  42. ),
  43. 'http://testhost/remote.php/webdav/testroot/',
  44. ),
  45. array(
  46. array(
  47. 'host' => 'testhost',
  48. 'root' => 'testroot',
  49. 'secure' => true
  50. ),
  51. 'https://testhost/remote.php/webdav/testroot/',
  52. ),
  53. array(
  54. array(
  55. 'host' => 'http://testhost',
  56. 'root' => 'testroot',
  57. 'secure' => false
  58. ),
  59. 'http://testhost/remote.php/webdav/testroot/',
  60. ),
  61. array(
  62. array(
  63. 'host' => 'https://testhost',
  64. 'root' => 'testroot',
  65. 'secure' => false
  66. ),
  67. 'https://testhost/remote.php/webdav/testroot/',
  68. ),
  69. array(
  70. array(
  71. 'host' => 'https://testhost/testroot',
  72. 'root' => '',
  73. 'secure' => false
  74. ),
  75. 'https://testhost/testroot/remote.php/webdav/',
  76. ),
  77. array(
  78. array(
  79. 'host' => 'https://testhost/testroot',
  80. 'root' => 'subdir',
  81. 'secure' => false
  82. ),
  83. 'https://testhost/testroot/remote.php/webdav/subdir/',
  84. ),
  85. array(
  86. array(
  87. 'host' => 'http://testhost/testroot',
  88. 'root' => 'subdir',
  89. 'secure' => true
  90. ),
  91. 'http://testhost/testroot/remote.php/webdav/subdir/',
  92. ),
  93. array(
  94. array(
  95. 'host' => 'http://testhost/testroot/',
  96. 'root' => '/subdir',
  97. 'secure' => false
  98. ),
  99. 'http://testhost/testroot/remote.php/webdav/subdir/',
  100. ),
  101. );
  102. }
  103. /**
  104. * @dataProvider configUrlProvider
  105. */
  106. public function testConfig($config, $expectedUri) {
  107. $config['user'] = 'someuser';
  108. $config['password'] = 'somepassword';
  109. $instance = new \OCA\Files_External\Lib\Storage\OwnCloud($config);
  110. $this->assertEquals($expectedUri, $instance->createBaseUri());
  111. }
  112. }