1
0

SharingServiceTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * @copyright 2024 Anna Larch <anna.larch@gmx.net>
  5. *
  6. * @author Anna Larch <anna.larch@gmx.net>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. namespace OCA\DAV\Tests\unit\DAV\Sharing;
  22. use OCA\DAV\CalDAV\Sharing\Service;
  23. use OCA\DAV\DAV\Sharing\SharingMapper;
  24. use OCA\DAV\DAV\Sharing\SharingService;
  25. use Test\TestCase;
  26. class SharingServiceTest extends TestCase {
  27. private SharingService $service;
  28. protected function setUp(): void {
  29. parent::setUp();
  30. $this->service = new Service($this->createMock(SharingMapper::class));
  31. }
  32. public function testHasGroupShare(): void {
  33. $oldShares = [
  34. [
  35. 'href' => 'principal:principals/groups/bob',
  36. 'commonName' => 'bob',
  37. 'status' => 1,
  38. 'readOnly' => true,
  39. '{http://owncloud.org/ns}principal' => 'principals/groups/bob',
  40. '{http://owncloud.org/ns}group-share' => true,
  41. ],
  42. [
  43. 'href' => 'principal:principals/users/bob',
  44. 'commonName' => 'bob',
  45. 'status' => 1,
  46. 'readOnly' => true,
  47. '{http://owncloud.org/ns}principal' => 'principals/users/bob',
  48. '{http://owncloud.org/ns}group-share' => false,
  49. ]
  50. ];
  51. $this->assertTrue($this->service->hasGroupShare($oldShares));
  52. $oldShares = [
  53. [
  54. 'href' => 'principal:principals/users/bob',
  55. 'commonName' => 'bob',
  56. 'status' => 1,
  57. 'readOnly' => true,
  58. '{http://owncloud.org/ns}principal' => 'principals/users/bob',
  59. '{http://owncloud.org/ns}group-share' => false,
  60. ]
  61. ];
  62. $this->assertFalse($this->service->hasGroupShare($oldShares));
  63. }
  64. }