AppleProvisioningNodeTest.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * @author Georg Ehrke <oc.list@georgehrke.com>
  4. *
  5. * @copyright Copyright (c) 2018 Georg Ehrke <oc.list@georgehrke.com>
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace OCA\DAV\Tests\unit\Provisioning\Apple;
  22. use OCA\DAV\Provisioning\Apple\AppleProvisioningNode;
  23. use OCP\AppFramework\Utility\ITimeFactory;
  24. use Sabre\DAV\PropPatch;
  25. use Test\TestCase;
  26. class AppleProvisioningNodeTest extends TestCase {
  27. /** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
  28. private $timeFactory;
  29. /** @var AppleProvisioningNode */
  30. private $node;
  31. protected function setUp(): void {
  32. parent::setUp();
  33. $this->timeFactory = $this->createMock(ITimeFactory::class);
  34. $this->node = new AppleProvisioningNode($this->timeFactory);
  35. }
  36. public function testGetName() {
  37. $this->assertEquals('apple-provisioning.mobileconfig', $this->node->getName());
  38. }
  39. public function testSetName() {
  40. $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
  41. $this->expectExceptionMessage('Renaming apple-provisioning.mobileconfig is forbidden');
  42. $this->node->setName('foo');
  43. }
  44. public function testGetLastModified() {
  45. $this->assertEquals(null, $this->node->getLastModified());
  46. }
  47. public function testDelete() {
  48. $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
  49. $this->expectExceptionMessage('apple-provisioning.mobileconfig may not be deleted');
  50. $this->node->delete();
  51. }
  52. public function testGetProperties() {
  53. $this->timeFactory->expects($this->at(0))
  54. ->method('getDateTime')
  55. ->willReturn(new \DateTime('2000-01-01'));
  56. $this->assertEquals([
  57. '{DAV:}getcontentlength' => 42,
  58. '{DAV:}getlastmodified' => 'Sat, 01 Jan 2000 00:00:00 +0000',
  59. ], $this->node->getProperties([]));
  60. }
  61. public function testGetPropPatch() {
  62. $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
  63. $this->expectExceptionMessage('apple-provisioning.mobileconfig\'s properties may not be altered.');
  64. $propPatch = $this->createMock(PropPatch::class);
  65. $this->node->propPatch($propPatch);
  66. }
  67. }