WebdavTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017-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\Storage;
  8. use OC\Files\Storage\DAV;
  9. use OC\Files\Type\Detection;
  10. /**
  11. * Class WebdavTest
  12. *
  13. * @group DB
  14. *
  15. * @package OCA\Files_External\Tests\Storage
  16. */
  17. class WebdavTest extends \Test\Files\Storage\Storage {
  18. protected function setUp(): void {
  19. parent::setUp();
  20. $id = $this->getUniqueID();
  21. $config = include('files_external/tests/config.webdav.php');
  22. if (!is_array($config) or !$config['run']) {
  23. $this->markTestSkipped('WebDAV backend not configured');
  24. }
  25. if (isset($config['wait'])) {
  26. $this->waitDelay = $config['wait'];
  27. }
  28. $config['root'] .= '/' . $id; //make sure we have an new empty folder to work in
  29. $this->instance = new DAV($config);
  30. $this->instance->mkdir('/');
  31. }
  32. protected function tearDown(): void {
  33. if ($this->instance) {
  34. $this->instance->rmdir('/');
  35. }
  36. parent::tearDown();
  37. }
  38. public function testMimetypeFallback() {
  39. $this->instance->file_put_contents('foo.bar', 'asd');
  40. /** @var Detection $mimeDetector */
  41. $mimeDetector = \OC::$server->getMimeTypeDetector();
  42. $mimeDetector->registerType('bar', 'application/x-bar');
  43. $this->assertEquals('application/x-bar', $this->instance->getMimeType('foo.bar'));
  44. }
  45. }