WebdavTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 Appelman <robin@icewind.nl>
  8. * @author Robin McCorkell <robin@mccorkell.me.uk>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. * @author Vincent Petry <vincent@nextcloud.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 OC\Files\Storage\DAV;
  30. use OC\Files\Type\Detection;
  31. /**
  32. * Class WebdavTest
  33. *
  34. * @group DB
  35. *
  36. * @package OCA\Files_External\Tests\Storage
  37. */
  38. class WebdavTest extends \Test\Files\Storage\Storage {
  39. protected function setUp(): void {
  40. parent::setUp();
  41. $id = $this->getUniqueID();
  42. $config = include('files_external/tests/config.webdav.php');
  43. if (!is_array($config) or !$config['run']) {
  44. $this->markTestSkipped('WebDAV backend not configured');
  45. }
  46. if (isset($config['wait'])) {
  47. $this->waitDelay = $config['wait'];
  48. }
  49. $config['root'] .= '/' . $id; //make sure we have an new empty folder to work in
  50. $this->instance = new DAV($config);
  51. $this->instance->mkdir('/');
  52. }
  53. protected function tearDown(): void {
  54. if ($this->instance) {
  55. $this->instance->rmdir('/');
  56. }
  57. parent::tearDown();
  58. }
  59. public function testMimetypeFallback() {
  60. $this->instance->file_put_contents('foo.bar', 'asd');
  61. /** @var Detection $mimeDetector */
  62. $mimeDetector = \OC::$server->getMimeTypeDetector();
  63. $mimeDetector->registerType('bar', 'application/x-bar');
  64. $this->assertEquals('application/x-bar', $this->instance->getMimeType('foo.bar'));
  65. }
  66. }