SwiftTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018-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 GuzzleHttp\Exception\ClientException;
  9. use OCA\Files_External\Lib\Storage\Swift;
  10. /**
  11. * Class SwiftTest
  12. *
  13. * @group DB
  14. *
  15. * @package OCA\Files_External\Tests\Storage
  16. */
  17. class SwiftTest extends \Test\Files\Storage\Storage {
  18. private $config;
  19. /**
  20. * @var Swift instance
  21. */
  22. protected $instance;
  23. protected function setUp(): void {
  24. parent::setUp();
  25. $this->config = include('files_external/tests/config.swift.php');
  26. if (!is_array($this->config) or !$this->config['run']) {
  27. $this->markTestSkipped('OpenStack Object Storage backend not configured');
  28. }
  29. $this->instance = new Swift($this->config);
  30. }
  31. protected function tearDown(): void {
  32. if ($this->instance) {
  33. try {
  34. $container = $this->instance->getContainer();
  35. $objects = $container->listObjects();
  36. foreach ($objects as $object) {
  37. $object->delete();
  38. }
  39. $container->delete();
  40. } catch (ClientException $e) {
  41. // container didn't exist, so we don't need to delete it
  42. }
  43. }
  44. parent::tearDown();
  45. }
  46. public function testStat(): void {
  47. $this->markTestSkipped('Swift doesn\'t update the parents folder mtime');
  48. }
  49. }