SharingServiceTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Tests\unit\DAV\Sharing;
  8. use OCA\DAV\CalDAV\Sharing\Service;
  9. use OCA\DAV\DAV\Sharing\SharingMapper;
  10. use OCA\DAV\DAV\Sharing\SharingService;
  11. use Test\TestCase;
  12. class SharingServiceTest extends TestCase {
  13. private SharingService $service;
  14. protected function setUp(): void {
  15. parent::setUp();
  16. $this->service = new Service($this->createMock(SharingMapper::class));
  17. }
  18. public function testHasGroupShare(): void {
  19. $oldShares = [
  20. [
  21. 'href' => 'principal:principals/groups/bob',
  22. 'commonName' => 'bob',
  23. 'status' => 1,
  24. 'readOnly' => true,
  25. '{http://owncloud.org/ns}principal' => 'principals/groups/bob',
  26. '{http://owncloud.org/ns}group-share' => true,
  27. ],
  28. [
  29. 'href' => 'principal:principals/users/bob',
  30. 'commonName' => 'bob',
  31. 'status' => 1,
  32. 'readOnly' => true,
  33. '{http://owncloud.org/ns}principal' => 'principals/users/bob',
  34. '{http://owncloud.org/ns}group-share' => false,
  35. ]
  36. ];
  37. $this->assertTrue($this->service->hasGroupShare($oldShares));
  38. $oldShares = [
  39. [
  40. 'href' => 'principal:principals/users/bob',
  41. 'commonName' => 'bob',
  42. 'status' => 1,
  43. 'readOnly' => true,
  44. '{http://owncloud.org/ns}principal' => 'principals/users/bob',
  45. '{http://owncloud.org/ns}group-share' => false,
  46. ]
  47. ];
  48. $this->assertFalse($this->service->hasGroupShare($oldShares));
  49. }
  50. }