@@ -17,108 +17,108 @@ |
||
17 | 17 | use Test\TestCase; |
18 | 18 | |
19 | 19 | class BaseTest extends TestCase { |
20 | - protected IUserManager&MockObject $userManager; |
|
21 | - protected IGroupManager&MockObject $groupManager; |
|
22 | - protected IURLGenerator&MockObject $url; |
|
23 | - protected Base&MockObject $provider; |
|
20 | + protected IUserManager&MockObject $userManager; |
|
21 | + protected IGroupManager&MockObject $groupManager; |
|
22 | + protected IURLGenerator&MockObject $url; |
|
23 | + protected Base&MockObject $provider; |
|
24 | 24 | |
25 | - protected function setUp(): void { |
|
26 | - parent::setUp(); |
|
27 | - $this->userManager = $this->createMock(IUserManager::class); |
|
28 | - $this->groupManager = $this->createMock(IGroupManager::class); |
|
29 | - $this->url = $this->createMock(IURLGenerator::class); |
|
30 | - $this->provider = $this->getMockBuilder(Base::class) |
|
31 | - ->setConstructorArgs([ |
|
32 | - $this->userManager, |
|
33 | - $this->groupManager, |
|
34 | - $this->url, |
|
35 | - ]) |
|
36 | - ->onlyMethods(['parse']) |
|
37 | - ->getMock(); |
|
38 | - } |
|
25 | + protected function setUp(): void { |
|
26 | + parent::setUp(); |
|
27 | + $this->userManager = $this->createMock(IUserManager::class); |
|
28 | + $this->groupManager = $this->createMock(IGroupManager::class); |
|
29 | + $this->url = $this->createMock(IURLGenerator::class); |
|
30 | + $this->provider = $this->getMockBuilder(Base::class) |
|
31 | + ->setConstructorArgs([ |
|
32 | + $this->userManager, |
|
33 | + $this->groupManager, |
|
34 | + $this->url, |
|
35 | + ]) |
|
36 | + ->onlyMethods(['parse']) |
|
37 | + ->getMock(); |
|
38 | + } |
|
39 | 39 | |
40 | - public static function dataSetSubjects(): array { |
|
41 | - return [ |
|
42 | - ['abc', []], |
|
43 | - ['{actor} created {calendar}', ['actor' => ['name' => 'abc'], 'calendar' => ['name' => 'xyz']]], |
|
44 | - ]; |
|
45 | - } |
|
40 | + public static function dataSetSubjects(): array { |
|
41 | + return [ |
|
42 | + ['abc', []], |
|
43 | + ['{actor} created {calendar}', ['actor' => ['name' => 'abc'], 'calendar' => ['name' => 'xyz']]], |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @dataProvider dataSetSubjects |
|
49 | - */ |
|
50 | - public function testSetSubjects(string $subject, array $parameters): void { |
|
51 | - $event = $this->createMock(IEvent::class); |
|
52 | - $event->expects($this->once()) |
|
53 | - ->method('setRichSubject') |
|
54 | - ->with($subject, $parameters) |
|
55 | - ->willReturnSelf(); |
|
56 | - $event->expects($this->never()) |
|
57 | - ->method('setParsedSubject'); |
|
47 | + /** |
|
48 | + * @dataProvider dataSetSubjects |
|
49 | + */ |
|
50 | + public function testSetSubjects(string $subject, array $parameters): void { |
|
51 | + $event = $this->createMock(IEvent::class); |
|
52 | + $event->expects($this->once()) |
|
53 | + ->method('setRichSubject') |
|
54 | + ->with($subject, $parameters) |
|
55 | + ->willReturnSelf(); |
|
56 | + $event->expects($this->never()) |
|
57 | + ->method('setParsedSubject'); |
|
58 | 58 | |
59 | - $this->invokePrivate($this->provider, 'setSubjects', [$event, $subject, $parameters]); |
|
60 | - } |
|
59 | + $this->invokePrivate($this->provider, 'setSubjects', [$event, $subject, $parameters]); |
|
60 | + } |
|
61 | 61 | |
62 | - public static function dataGenerateCalendarParameter(): array { |
|
63 | - return [ |
|
64 | - [['id' => 23, 'uri' => 'foo', 'name' => 'bar'], 'bar'], |
|
65 | - [['id' => 42, 'uri' => 'foo', 'name' => 'Personal'], 'Personal'], |
|
66 | - [['id' => 42, 'uri' => 'personal', 'name' => 'bar'], 'bar'], |
|
67 | - [['id' => 42, 'uri' => 'personal', 'name' => 'Personal'], 't(Personal)'], |
|
68 | - ]; |
|
69 | - } |
|
62 | + public static function dataGenerateCalendarParameter(): array { |
|
63 | + return [ |
|
64 | + [['id' => 23, 'uri' => 'foo', 'name' => 'bar'], 'bar'], |
|
65 | + [['id' => 42, 'uri' => 'foo', 'name' => 'Personal'], 'Personal'], |
|
66 | + [['id' => 42, 'uri' => 'personal', 'name' => 'bar'], 'bar'], |
|
67 | + [['id' => 42, 'uri' => 'personal', 'name' => 'Personal'], 't(Personal)'], |
|
68 | + ]; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @dataProvider dataGenerateCalendarParameter |
|
73 | - */ |
|
74 | - public function testGenerateCalendarParameter(array $data, string $name): void { |
|
75 | - $l = $this->createMock(IL10N::class); |
|
76 | - $l->expects($this->any()) |
|
77 | - ->method('t') |
|
78 | - ->willReturnCallback(function ($string, $args) { |
|
79 | - return 't(' . vsprintf($string, $args) . ')'; |
|
80 | - }); |
|
71 | + /** |
|
72 | + * @dataProvider dataGenerateCalendarParameter |
|
73 | + */ |
|
74 | + public function testGenerateCalendarParameter(array $data, string $name): void { |
|
75 | + $l = $this->createMock(IL10N::class); |
|
76 | + $l->expects($this->any()) |
|
77 | + ->method('t') |
|
78 | + ->willReturnCallback(function ($string, $args) { |
|
79 | + return 't(' . vsprintf($string, $args) . ')'; |
|
80 | + }); |
|
81 | 81 | |
82 | - $this->assertEquals([ |
|
83 | - 'type' => 'calendar', |
|
84 | - 'id' => $data['id'], |
|
85 | - 'name' => $name, |
|
86 | - ], $this->invokePrivate($this->provider, 'generateCalendarParameter', [$data, $l])); |
|
87 | - } |
|
82 | + $this->assertEquals([ |
|
83 | + 'type' => 'calendar', |
|
84 | + 'id' => $data['id'], |
|
85 | + 'name' => $name, |
|
86 | + ], $this->invokePrivate($this->provider, 'generateCalendarParameter', [$data, $l])); |
|
87 | + } |
|
88 | 88 | |
89 | - public static function dataGenerateLegacyCalendarParameter(): array { |
|
90 | - return [ |
|
91 | - [23, 'c1'], |
|
92 | - [42, 'c2'], |
|
93 | - ]; |
|
94 | - } |
|
89 | + public static function dataGenerateLegacyCalendarParameter(): array { |
|
90 | + return [ |
|
91 | + [23, 'c1'], |
|
92 | + [42, 'c2'], |
|
93 | + ]; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @dataProvider dataGenerateLegacyCalendarParameter |
|
98 | - */ |
|
99 | - public function testGenerateLegacyCalendarParameter(int $id, string $name): void { |
|
100 | - $this->assertEquals([ |
|
101 | - 'type' => 'calendar', |
|
102 | - 'id' => $id, |
|
103 | - 'name' => $name, |
|
104 | - ], $this->invokePrivate($this->provider, 'generateLegacyCalendarParameter', [$id, $name])); |
|
105 | - } |
|
96 | + /** |
|
97 | + * @dataProvider dataGenerateLegacyCalendarParameter |
|
98 | + */ |
|
99 | + public function testGenerateLegacyCalendarParameter(int $id, string $name): void { |
|
100 | + $this->assertEquals([ |
|
101 | + 'type' => 'calendar', |
|
102 | + 'id' => $id, |
|
103 | + 'name' => $name, |
|
104 | + ], $this->invokePrivate($this->provider, 'generateLegacyCalendarParameter', [$id, $name])); |
|
105 | + } |
|
106 | 106 | |
107 | - public static function dataGenerateGroupParameter(): array { |
|
108 | - return [ |
|
109 | - ['g1'], |
|
110 | - ['g2'], |
|
111 | - ]; |
|
112 | - } |
|
107 | + public static function dataGenerateGroupParameter(): array { |
|
108 | + return [ |
|
109 | + ['g1'], |
|
110 | + ['g2'], |
|
111 | + ]; |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @dataProvider dataGenerateGroupParameter |
|
116 | - */ |
|
117 | - public function testGenerateGroupParameter(string $gid): void { |
|
118 | - $this->assertEquals([ |
|
119 | - 'type' => 'user-group', |
|
120 | - 'id' => $gid, |
|
121 | - 'name' => $gid, |
|
122 | - ], $this->invokePrivate($this->provider, 'generateGroupParameter', [$gid])); |
|
123 | - } |
|
114 | + /** |
|
115 | + * @dataProvider dataGenerateGroupParameter |
|
116 | + */ |
|
117 | + public function testGenerateGroupParameter(string $gid): void { |
|
118 | + $this->assertEquals([ |
|
119 | + 'type' => 'user-group', |
|
120 | + 'id' => $gid, |
|
121 | + 'name' => $gid, |
|
122 | + ], $this->invokePrivate($this->provider, 'generateGroupParameter', [$gid])); |
|
123 | + } |
|
124 | 124 | } |
@@ -15,85 +15,85 @@ |
||
15 | 15 | use Test\TestCase; |
16 | 16 | |
17 | 17 | class GenericTest extends TestCase { |
18 | - public static function dataSettings(): array { |
|
19 | - return [ |
|
20 | - [Calendar::class], |
|
21 | - [Event::class], |
|
22 | - [Todo::class], |
|
23 | - ]; |
|
24 | - } |
|
18 | + public static function dataSettings(): array { |
|
19 | + return [ |
|
20 | + [Calendar::class], |
|
21 | + [Event::class], |
|
22 | + [Todo::class], |
|
23 | + ]; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @dataProvider dataSettings |
|
28 | - */ |
|
29 | - public function testImplementsInterface(string $settingClass): void { |
|
30 | - $setting = Server::get($settingClass); |
|
31 | - $this->assertInstanceOf(ISetting::class, $setting); |
|
32 | - } |
|
26 | + /** |
|
27 | + * @dataProvider dataSettings |
|
28 | + */ |
|
29 | + public function testImplementsInterface(string $settingClass): void { |
|
30 | + $setting = Server::get($settingClass); |
|
31 | + $this->assertInstanceOf(ISetting::class, $setting); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @dataProvider dataSettings |
|
36 | - */ |
|
37 | - public function testGetIdentifier(string $settingClass): void { |
|
38 | - /** @var ISetting $setting */ |
|
39 | - $setting = Server::get($settingClass); |
|
40 | - $this->assertIsString($setting->getIdentifier()); |
|
41 | - } |
|
34 | + /** |
|
35 | + * @dataProvider dataSettings |
|
36 | + */ |
|
37 | + public function testGetIdentifier(string $settingClass): void { |
|
38 | + /** @var ISetting $setting */ |
|
39 | + $setting = Server::get($settingClass); |
|
40 | + $this->assertIsString($setting->getIdentifier()); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @dataProvider dataSettings |
|
45 | - */ |
|
46 | - public function testGetName(string $settingClass): void { |
|
47 | - /** @var ISetting $setting */ |
|
48 | - $setting = Server::get($settingClass); |
|
49 | - $this->assertIsString($setting->getName()); |
|
50 | - } |
|
43 | + /** |
|
44 | + * @dataProvider dataSettings |
|
45 | + */ |
|
46 | + public function testGetName(string $settingClass): void { |
|
47 | + /** @var ISetting $setting */ |
|
48 | + $setting = Server::get($settingClass); |
|
49 | + $this->assertIsString($setting->getName()); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @dataProvider dataSettings |
|
54 | - */ |
|
55 | - public function testGetPriority(string $settingClass): void { |
|
56 | - /** @var ISetting $setting */ |
|
57 | - $setting = Server::get($settingClass); |
|
58 | - $priority = $setting->getPriority(); |
|
59 | - $this->assertIsInt($setting->getPriority()); |
|
60 | - $this->assertGreaterThanOrEqual(0, $priority); |
|
61 | - $this->assertLessThanOrEqual(100, $priority); |
|
62 | - } |
|
52 | + /** |
|
53 | + * @dataProvider dataSettings |
|
54 | + */ |
|
55 | + public function testGetPriority(string $settingClass): void { |
|
56 | + /** @var ISetting $setting */ |
|
57 | + $setting = Server::get($settingClass); |
|
58 | + $priority = $setting->getPriority(); |
|
59 | + $this->assertIsInt($setting->getPriority()); |
|
60 | + $this->assertGreaterThanOrEqual(0, $priority); |
|
61 | + $this->assertLessThanOrEqual(100, $priority); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @dataProvider dataSettings |
|
66 | - */ |
|
67 | - public function testCanChangeStream(string $settingClass): void { |
|
68 | - /** @var ISetting $setting */ |
|
69 | - $setting = Server::get($settingClass); |
|
70 | - $this->assertIsBool($setting->canChangeStream()); |
|
71 | - } |
|
64 | + /** |
|
65 | + * @dataProvider dataSettings |
|
66 | + */ |
|
67 | + public function testCanChangeStream(string $settingClass): void { |
|
68 | + /** @var ISetting $setting */ |
|
69 | + $setting = Server::get($settingClass); |
|
70 | + $this->assertIsBool($setting->canChangeStream()); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @dataProvider dataSettings |
|
75 | - */ |
|
76 | - public function testIsDefaultEnabledStream(string $settingClass): void { |
|
77 | - /** @var ISetting $setting */ |
|
78 | - $setting = Server::get($settingClass); |
|
79 | - $this->assertIsBool($setting->isDefaultEnabledStream()); |
|
80 | - } |
|
73 | + /** |
|
74 | + * @dataProvider dataSettings |
|
75 | + */ |
|
76 | + public function testIsDefaultEnabledStream(string $settingClass): void { |
|
77 | + /** @var ISetting $setting */ |
|
78 | + $setting = Server::get($settingClass); |
|
79 | + $this->assertIsBool($setting->isDefaultEnabledStream()); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @dataProvider dataSettings |
|
84 | - */ |
|
85 | - public function testCanChangeMail(string $settingClass): void { |
|
86 | - /** @var ISetting $setting */ |
|
87 | - $setting = Server::get($settingClass); |
|
88 | - $this->assertIsBool($setting->canChangeMail()); |
|
89 | - } |
|
82 | + /** |
|
83 | + * @dataProvider dataSettings |
|
84 | + */ |
|
85 | + public function testCanChangeMail(string $settingClass): void { |
|
86 | + /** @var ISetting $setting */ |
|
87 | + $setting = Server::get($settingClass); |
|
88 | + $this->assertIsBool($setting->canChangeMail()); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @dataProvider dataSettings |
|
93 | - */ |
|
94 | - public function testIsDefaultEnabledMail(string $settingClass): void { |
|
95 | - /** @var ISetting $setting */ |
|
96 | - $setting = Server::get($settingClass); |
|
97 | - $this->assertIsBool($setting->isDefaultEnabledMail()); |
|
98 | - } |
|
91 | + /** |
|
92 | + * @dataProvider dataSettings |
|
93 | + */ |
|
94 | + public function testIsDefaultEnabledMail(string $settingClass): void { |
|
95 | + /** @var ISetting $setting */ |
|
96 | + $setting = Server::get($settingClass); |
|
97 | + $this->assertIsBool($setting->isDefaultEnabledMail()); |
|
98 | + } |
|
99 | 99 | } |
@@ -17,76 +17,76 @@ |
||
17 | 17 | * @group DB |
18 | 18 | */ |
19 | 19 | class GenericTest extends TestCase { |
20 | - public static function dataFilters(): array { |
|
21 | - return [ |
|
22 | - [Calendar::class], |
|
23 | - [Todo::class], |
|
24 | - ]; |
|
25 | - } |
|
20 | + public static function dataFilters(): array { |
|
21 | + return [ |
|
22 | + [Calendar::class], |
|
23 | + [Todo::class], |
|
24 | + ]; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @dataProvider dataFilters |
|
29 | - */ |
|
30 | - public function testImplementsInterface(string $filterClass): void { |
|
31 | - $filter = Server::get($filterClass); |
|
32 | - $this->assertInstanceOf(IFilter::class, $filter); |
|
33 | - } |
|
27 | + /** |
|
28 | + * @dataProvider dataFilters |
|
29 | + */ |
|
30 | + public function testImplementsInterface(string $filterClass): void { |
|
31 | + $filter = Server::get($filterClass); |
|
32 | + $this->assertInstanceOf(IFilter::class, $filter); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @dataProvider dataFilters |
|
37 | - */ |
|
38 | - public function testGetIdentifier(string $filterClass): void { |
|
39 | - /** @var IFilter $filter */ |
|
40 | - $filter = Server::get($filterClass); |
|
41 | - $this->assertIsString($filter->getIdentifier()); |
|
42 | - } |
|
35 | + /** |
|
36 | + * @dataProvider dataFilters |
|
37 | + */ |
|
38 | + public function testGetIdentifier(string $filterClass): void { |
|
39 | + /** @var IFilter $filter */ |
|
40 | + $filter = Server::get($filterClass); |
|
41 | + $this->assertIsString($filter->getIdentifier()); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @dataProvider dataFilters |
|
46 | - */ |
|
47 | - public function testGetName(string $filterClass): void { |
|
48 | - /** @var IFilter $filter */ |
|
49 | - $filter = Server::get($filterClass); |
|
50 | - $this->assertIsString($filter->getName()); |
|
51 | - } |
|
44 | + /** |
|
45 | + * @dataProvider dataFilters |
|
46 | + */ |
|
47 | + public function testGetName(string $filterClass): void { |
|
48 | + /** @var IFilter $filter */ |
|
49 | + $filter = Server::get($filterClass); |
|
50 | + $this->assertIsString($filter->getName()); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @dataProvider dataFilters |
|
55 | - */ |
|
56 | - public function testGetPriority(string $filterClass): void { |
|
57 | - /** @var IFilter $filter */ |
|
58 | - $filter = Server::get($filterClass); |
|
59 | - $priority = $filter->getPriority(); |
|
60 | - $this->assertIsInt($filter->getPriority()); |
|
61 | - $this->assertGreaterThanOrEqual(0, $priority); |
|
62 | - $this->assertLessThanOrEqual(100, $priority); |
|
63 | - } |
|
53 | + /** |
|
54 | + * @dataProvider dataFilters |
|
55 | + */ |
|
56 | + public function testGetPriority(string $filterClass): void { |
|
57 | + /** @var IFilter $filter */ |
|
58 | + $filter = Server::get($filterClass); |
|
59 | + $priority = $filter->getPriority(); |
|
60 | + $this->assertIsInt($filter->getPriority()); |
|
61 | + $this->assertGreaterThanOrEqual(0, $priority); |
|
62 | + $this->assertLessThanOrEqual(100, $priority); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @dataProvider dataFilters |
|
67 | - */ |
|
68 | - public function testGetIcon(string $filterClass): void { |
|
69 | - /** @var IFilter $filter */ |
|
70 | - $filter = Server::get($filterClass); |
|
71 | - $this->assertIsString($filter->getIcon()); |
|
72 | - $this->assertStringStartsWith('http', $filter->getIcon()); |
|
73 | - } |
|
65 | + /** |
|
66 | + * @dataProvider dataFilters |
|
67 | + */ |
|
68 | + public function testGetIcon(string $filterClass): void { |
|
69 | + /** @var IFilter $filter */ |
|
70 | + $filter = Server::get($filterClass); |
|
71 | + $this->assertIsString($filter->getIcon()); |
|
72 | + $this->assertStringStartsWith('http', $filter->getIcon()); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @dataProvider dataFilters |
|
77 | - */ |
|
78 | - public function testFilterTypes(string $filterClass): void { |
|
79 | - /** @var IFilter $filter */ |
|
80 | - $filter = Server::get($filterClass); |
|
81 | - $this->assertIsArray($filter->filterTypes([])); |
|
82 | - } |
|
75 | + /** |
|
76 | + * @dataProvider dataFilters |
|
77 | + */ |
|
78 | + public function testFilterTypes(string $filterClass): void { |
|
79 | + /** @var IFilter $filter */ |
|
80 | + $filter = Server::get($filterClass); |
|
81 | + $this->assertIsArray($filter->filterTypes([])); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @dataProvider dataFilters |
|
86 | - */ |
|
87 | - public function testAllowedApps(string $filterClass): void { |
|
88 | - /** @var IFilter $filter */ |
|
89 | - $filter = Server::get($filterClass); |
|
90 | - $this->assertIsArray($filter->allowedApps()); |
|
91 | - } |
|
84 | + /** |
|
85 | + * @dataProvider dataFilters |
|
86 | + */ |
|
87 | + public function testAllowedApps(string $filterClass): void { |
|
88 | + /** @var IFilter $filter */ |
|
89 | + $filter = Server::get($filterClass); |
|
90 | + $this->assertIsArray($filter->allowedApps()); |
|
91 | + } |
|
92 | 92 | } |
@@ -15,53 +15,53 @@ |
||
15 | 15 | use Test\TestCase; |
16 | 16 | |
17 | 17 | class TodoTest extends TestCase { |
18 | - protected IURLGenerator&MockObject $url; |
|
19 | - protected IFilter $filter; |
|
18 | + protected IURLGenerator&MockObject $url; |
|
19 | + protected IFilter $filter; |
|
20 | 20 | |
21 | - protected function setUp(): void { |
|
22 | - parent::setUp(); |
|
23 | - $this->url = $this->createMock(IURLGenerator::class); |
|
24 | - $l = $this->createMock(IL10N::class); |
|
25 | - $l->expects($this->any()) |
|
26 | - ->method('t') |
|
27 | - ->willReturnCallback(function ($string, $args) { |
|
28 | - return vsprintf($string, $args); |
|
29 | - }); |
|
21 | + protected function setUp(): void { |
|
22 | + parent::setUp(); |
|
23 | + $this->url = $this->createMock(IURLGenerator::class); |
|
24 | + $l = $this->createMock(IL10N::class); |
|
25 | + $l->expects($this->any()) |
|
26 | + ->method('t') |
|
27 | + ->willReturnCallback(function ($string, $args) { |
|
28 | + return vsprintf($string, $args); |
|
29 | + }); |
|
30 | 30 | |
31 | - $this->filter = new Todo( |
|
32 | - $l, $this->url |
|
33 | - ); |
|
34 | - } |
|
31 | + $this->filter = new Todo( |
|
32 | + $l, $this->url |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | - public function testGetIcon(): void { |
|
37 | - $this->url->expects($this->once()) |
|
38 | - ->method('imagePath') |
|
39 | - ->with('core', 'actions/checkmark.svg') |
|
40 | - ->willReturn('path-to-icon'); |
|
36 | + public function testGetIcon(): void { |
|
37 | + $this->url->expects($this->once()) |
|
38 | + ->method('imagePath') |
|
39 | + ->with('core', 'actions/checkmark.svg') |
|
40 | + ->willReturn('path-to-icon'); |
|
41 | 41 | |
42 | - $this->url->expects($this->once()) |
|
43 | - ->method('getAbsoluteURL') |
|
44 | - ->with('path-to-icon') |
|
45 | - ->willReturn('absolute-path-to-icon'); |
|
42 | + $this->url->expects($this->once()) |
|
43 | + ->method('getAbsoluteURL') |
|
44 | + ->with('path-to-icon') |
|
45 | + ->willReturn('absolute-path-to-icon'); |
|
46 | 46 | |
47 | - $this->assertEquals('absolute-path-to-icon', $this->filter->getIcon()); |
|
48 | - } |
|
47 | + $this->assertEquals('absolute-path-to-icon', $this->filter->getIcon()); |
|
48 | + } |
|
49 | 49 | |
50 | - public static function dataFilterTypes(): array { |
|
51 | - return [ |
|
52 | - [[], []], |
|
53 | - [['calendar_todo'], ['calendar_todo']], |
|
54 | - [['calendar', 'calendar_event', 'calendar_todo'], ['calendar_todo']], |
|
55 | - [['calendar', 'calendar_todo', 'files'], ['calendar_todo']], |
|
56 | - ]; |
|
57 | - } |
|
50 | + public static function dataFilterTypes(): array { |
|
51 | + return [ |
|
52 | + [[], []], |
|
53 | + [['calendar_todo'], ['calendar_todo']], |
|
54 | + [['calendar', 'calendar_event', 'calendar_todo'], ['calendar_todo']], |
|
55 | + [['calendar', 'calendar_todo', 'files'], ['calendar_todo']], |
|
56 | + ]; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @dataProvider dataFilterTypes |
|
61 | - * @param string[] $types |
|
62 | - * @param string[] $expected |
|
63 | - */ |
|
64 | - public function testFilterTypes(array $types, array $expected): void { |
|
65 | - $this->assertEquals($expected, $this->filter->filterTypes($types)); |
|
66 | - } |
|
59 | + /** |
|
60 | + * @dataProvider dataFilterTypes |
|
61 | + * @param string[] $types |
|
62 | + * @param string[] $expected |
|
63 | + */ |
|
64 | + public function testFilterTypes(array $types, array $expected): void { |
|
65 | + $this->assertEquals($expected, $this->filter->filterTypes($types)); |
|
66 | + } |
|
67 | 67 | } |
@@ -15,53 +15,53 @@ |
||
15 | 15 | use Test\TestCase; |
16 | 16 | |
17 | 17 | class CalendarTest extends TestCase { |
18 | - protected IURLGenerator&MockObject $url; |
|
19 | - protected IFilter $filter; |
|
18 | + protected IURLGenerator&MockObject $url; |
|
19 | + protected IFilter $filter; |
|
20 | 20 | |
21 | - protected function setUp(): void { |
|
22 | - parent::setUp(); |
|
23 | - $this->url = $this->createMock(IURLGenerator::class); |
|
24 | - $l = $this->createMock(IL10N::class); |
|
25 | - $l->expects($this->any()) |
|
26 | - ->method('t') |
|
27 | - ->willReturnCallback(function ($string, $args) { |
|
28 | - return vsprintf($string, $args); |
|
29 | - }); |
|
21 | + protected function setUp(): void { |
|
22 | + parent::setUp(); |
|
23 | + $this->url = $this->createMock(IURLGenerator::class); |
|
24 | + $l = $this->createMock(IL10N::class); |
|
25 | + $l->expects($this->any()) |
|
26 | + ->method('t') |
|
27 | + ->willReturnCallback(function ($string, $args) { |
|
28 | + return vsprintf($string, $args); |
|
29 | + }); |
|
30 | 30 | |
31 | - $this->filter = new Calendar( |
|
32 | - $l, $this->url |
|
33 | - ); |
|
34 | - } |
|
31 | + $this->filter = new Calendar( |
|
32 | + $l, $this->url |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | - public function testGetIcon(): void { |
|
37 | - $this->url->expects($this->once()) |
|
38 | - ->method('imagePath') |
|
39 | - ->with('core', 'places/calendar.svg') |
|
40 | - ->willReturn('path-to-icon'); |
|
36 | + public function testGetIcon(): void { |
|
37 | + $this->url->expects($this->once()) |
|
38 | + ->method('imagePath') |
|
39 | + ->with('core', 'places/calendar.svg') |
|
40 | + ->willReturn('path-to-icon'); |
|
41 | 41 | |
42 | - $this->url->expects($this->once()) |
|
43 | - ->method('getAbsoluteURL') |
|
44 | - ->with('path-to-icon') |
|
45 | - ->willReturn('absolute-path-to-icon'); |
|
42 | + $this->url->expects($this->once()) |
|
43 | + ->method('getAbsoluteURL') |
|
44 | + ->with('path-to-icon') |
|
45 | + ->willReturn('absolute-path-to-icon'); |
|
46 | 46 | |
47 | - $this->assertEquals('absolute-path-to-icon', $this->filter->getIcon()); |
|
48 | - } |
|
47 | + $this->assertEquals('absolute-path-to-icon', $this->filter->getIcon()); |
|
48 | + } |
|
49 | 49 | |
50 | - public static function dataFilterTypes(): array { |
|
51 | - return [ |
|
52 | - [[], []], |
|
53 | - [['calendar', 'calendar_event'], ['calendar', 'calendar_event']], |
|
54 | - [['calendar', 'calendar_event', 'calendar_todo'], ['calendar', 'calendar_event']], |
|
55 | - [['calendar', 'calendar_event', 'files'], ['calendar', 'calendar_event']], |
|
56 | - ]; |
|
57 | - } |
|
50 | + public static function dataFilterTypes(): array { |
|
51 | + return [ |
|
52 | + [[], []], |
|
53 | + [['calendar', 'calendar_event'], ['calendar', 'calendar_event']], |
|
54 | + [['calendar', 'calendar_event', 'calendar_todo'], ['calendar', 'calendar_event']], |
|
55 | + [['calendar', 'calendar_event', 'files'], ['calendar', 'calendar_event']], |
|
56 | + ]; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @dataProvider dataFilterTypes |
|
61 | - * @param string[] $types |
|
62 | - * @param string[] $expected |
|
63 | - */ |
|
64 | - public function testFilterTypes(array $types, array $expected): void { |
|
65 | - $this->assertEquals($expected, $this->filter->filterTypes($types)); |
|
66 | - } |
|
59 | + /** |
|
60 | + * @dataProvider dataFilterTypes |
|
61 | + * @param string[] $types |
|
62 | + * @param string[] $expected |
|
63 | + */ |
|
64 | + public function testFilterTypes(array $types, array $expected): void { |
|
65 | + $this->assertEquals($expected, $this->filter->filterTypes($types)); |
|
66 | + } |
|
67 | 67 | } |
@@ -21,335 +21,335 @@ |
||
21 | 21 | use Test\TestCase; |
22 | 22 | |
23 | 23 | class BackendTest extends TestCase { |
24 | - protected IManager&MockObject $activityManager; |
|
25 | - protected IGroupManager&MockObject $groupManager; |
|
26 | - protected IUserSession&MockObject $userSession; |
|
27 | - protected IAppManager&MockObject $appManager; |
|
28 | - protected IUserManager&MockObject $userManager; |
|
29 | - |
|
30 | - protected function setUp(): void { |
|
31 | - parent::setUp(); |
|
32 | - $this->activityManager = $this->createMock(IManager::class); |
|
33 | - $this->groupManager = $this->createMock(IGroupManager::class); |
|
34 | - $this->userSession = $this->createMock(IUserSession::class); |
|
35 | - $this->appManager = $this->createMock(IAppManager::class); |
|
36 | - $this->userManager = $this->createMock(IUserManager::class); |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * @return Backend|(Backend&MockObject) |
|
41 | - */ |
|
42 | - protected function getBackend(array $methods = []): Backend { |
|
43 | - if (empty($methods)) { |
|
44 | - return new Backend( |
|
45 | - $this->activityManager, |
|
46 | - $this->groupManager, |
|
47 | - $this->userSession, |
|
48 | - $this->appManager, |
|
49 | - $this->userManager |
|
50 | - ); |
|
51 | - } else { |
|
52 | - return $this->getMockBuilder(Backend::class) |
|
53 | - ->setConstructorArgs([ |
|
54 | - $this->activityManager, |
|
55 | - $this->groupManager, |
|
56 | - $this->userSession, |
|
57 | - $this->appManager, |
|
58 | - $this->userManager |
|
59 | - ]) |
|
60 | - ->onlyMethods($methods) |
|
61 | - ->getMock(); |
|
62 | - } |
|
63 | - } |
|
64 | - |
|
65 | - public static function dataCallTriggerCalendarActivity(): array { |
|
66 | - return [ |
|
67 | - ['onCalendarAdd', [['data']], Calendar::SUBJECT_ADD, [['data'], [], []]], |
|
68 | - ['onCalendarUpdate', [['data'], ['shares'], ['changed-properties']], Calendar::SUBJECT_UPDATE, [['data'], ['shares'], ['changed-properties']]], |
|
69 | - ['onCalendarDelete', [['data'], ['shares']], Calendar::SUBJECT_DELETE, [['data'], ['shares'], []]], |
|
70 | - ['onCalendarPublication', [['data'], true], Calendar::SUBJECT_PUBLISH, [['data'], [], []]], |
|
71 | - ]; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @dataProvider dataCallTriggerCalendarActivity |
|
76 | - */ |
|
77 | - public function testCallTriggerCalendarActivity(string $method, array $payload, string $expectedSubject, array $expectedPayload): void { |
|
78 | - $backend = $this->getBackend(['triggerCalendarActivity']); |
|
79 | - $backend->expects($this->once()) |
|
80 | - ->method('triggerCalendarActivity') |
|
81 | - ->willReturnCallback(function () use ($expectedPayload, $expectedSubject): void { |
|
82 | - $arguments = func_get_args(); |
|
83 | - $this->assertSame($expectedSubject, array_shift($arguments)); |
|
84 | - $this->assertEquals($expectedPayload, $arguments); |
|
85 | - }); |
|
86 | - |
|
87 | - call_user_func_array([$backend, $method], $payload); |
|
88 | - } |
|
89 | - |
|
90 | - public static function dataTriggerCalendarActivity(): array { |
|
91 | - return [ |
|
92 | - // Add calendar |
|
93 | - [Calendar::SUBJECT_ADD, [], [], [], '', '', null, []], |
|
94 | - [Calendar::SUBJECT_ADD, [ |
|
95 | - 'principaluri' => 'principal/user/admin', |
|
96 | - 'id' => 42, |
|
97 | - 'uri' => 'this-uri', |
|
98 | - '{DAV:}displayname' => 'Name of calendar', |
|
99 | - ], [], [], '', 'admin', null, ['admin']], |
|
100 | - [Calendar::SUBJECT_ADD, [ |
|
101 | - 'principaluri' => 'principal/user/admin', |
|
102 | - 'id' => 42, |
|
103 | - 'uri' => 'this-uri', |
|
104 | - '{DAV:}displayname' => 'Name of calendar', |
|
105 | - ], [], [], 'test2', 'test2', null, ['admin']], |
|
106 | - |
|
107 | - // Update calendar |
|
108 | - [Calendar::SUBJECT_UPDATE, [], [], [], '', '', null, []], |
|
109 | - // No visible change - owner only |
|
110 | - [Calendar::SUBJECT_UPDATE, [ |
|
111 | - 'principaluri' => 'principal/user/admin', |
|
112 | - 'id' => 42, |
|
113 | - 'uri' => 'this-uri', |
|
114 | - '{DAV:}displayname' => 'Name of calendar', |
|
115 | - ], ['shares'], [], '', 'admin', null, ['admin']], |
|
116 | - // Visible change |
|
117 | - [Calendar::SUBJECT_UPDATE, [ |
|
118 | - 'principaluri' => 'principal/user/admin', |
|
119 | - 'id' => 42, |
|
120 | - 'uri' => 'this-uri', |
|
121 | - '{DAV:}displayname' => 'Name of calendar', |
|
122 | - ], ['shares'], ['{DAV:}displayname' => 'Name'], '', 'admin', ['user1'], ['user1', 'admin']], |
|
123 | - [Calendar::SUBJECT_UPDATE, [ |
|
124 | - 'principaluri' => 'principal/user/admin', |
|
125 | - 'id' => 42, |
|
126 | - 'uri' => 'this-uri', |
|
127 | - '{DAV:}displayname' => 'Name of calendar', |
|
128 | - ], ['shares'], ['{DAV:}displayname' => 'Name'], 'test2', 'test2', ['user1'], ['user1', 'admin']], |
|
129 | - |
|
130 | - // Delete calendar |
|
131 | - [Calendar::SUBJECT_DELETE, [], [], [], '', '', null, []], |
|
132 | - [Calendar::SUBJECT_DELETE, [ |
|
133 | - 'principaluri' => 'principal/user/admin', |
|
134 | - 'id' => 42, |
|
135 | - 'uri' => 'this-uri', |
|
136 | - '{DAV:}displayname' => 'Name of calendar', |
|
137 | - ], ['shares'], [], '', 'admin', [], ['admin']], |
|
138 | - [Calendar::SUBJECT_DELETE, [ |
|
139 | - 'principaluri' => 'principal/user/admin', |
|
140 | - 'id' => 42, |
|
141 | - 'uri' => 'this-uri', |
|
142 | - '{DAV:}displayname' => 'Name of calendar', |
|
143 | - ], ['shares'], [], '', 'admin', ['user1'], ['user1', 'admin']], |
|
144 | - [Calendar::SUBJECT_DELETE, [ |
|
145 | - 'principaluri' => 'principal/user/admin', |
|
146 | - 'id' => 42, |
|
147 | - 'uri' => 'this-uri', |
|
148 | - '{DAV:}displayname' => 'Name of calendar', |
|
149 | - ], ['shares'], [], 'test2', 'test2', ['user1'], ['user1', 'admin']], |
|
150 | - |
|
151 | - // Publish calendar |
|
152 | - [Calendar::SUBJECT_PUBLISH, [], [], [], '', '', null, []], |
|
153 | - [Calendar::SUBJECT_PUBLISH, [ |
|
154 | - 'principaluri' => 'principal/user/admin', |
|
155 | - 'id' => 42, |
|
156 | - 'uri' => 'this-uri', |
|
157 | - '{DAV:}displayname' => 'Name of calendar', |
|
158 | - ], ['shares'], [], '', 'admin', [], ['admin']], |
|
159 | - |
|
160 | - // Unpublish calendar |
|
161 | - [Calendar::SUBJECT_UNPUBLISH, [], [], [], '', '', null, []], |
|
162 | - [Calendar::SUBJECT_UNPUBLISH, [ |
|
163 | - 'principaluri' => 'principal/user/admin', |
|
164 | - 'id' => 42, |
|
165 | - 'uri' => 'this-uri', |
|
166 | - '{DAV:}displayname' => 'Name of calendar', |
|
167 | - ], ['shares'], [], '', 'admin', [], ['admin']], |
|
168 | - ]; |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * @dataProvider dataTriggerCalendarActivity |
|
173 | - */ |
|
174 | - public function testTriggerCalendarActivity(string $action, array $data, array $shares, array $changedProperties, string $currentUser, string $author, ?array $shareUsers, array $users): void { |
|
175 | - $backend = $this->getBackend(['getUsersForShares']); |
|
176 | - |
|
177 | - if ($shareUsers === null) { |
|
178 | - $backend->expects($this->never()) |
|
179 | - ->method('getUsersForShares'); |
|
180 | - } else { |
|
181 | - $backend->expects($this->once()) |
|
182 | - ->method('getUsersForShares') |
|
183 | - ->with($shares) |
|
184 | - ->willReturn($shareUsers); |
|
185 | - } |
|
186 | - |
|
187 | - if ($author !== '') { |
|
188 | - if ($currentUser !== '') { |
|
189 | - $this->userSession->expects($this->once()) |
|
190 | - ->method('getUser') |
|
191 | - ->willReturn($this->getUserMock($currentUser)); |
|
192 | - } else { |
|
193 | - $this->userSession->expects($this->once()) |
|
194 | - ->method('getUser') |
|
195 | - ->willReturn(null); |
|
196 | - } |
|
197 | - |
|
198 | - $event = $this->createMock(IEvent::class); |
|
199 | - $this->activityManager->expects($this->once()) |
|
200 | - ->method('generateEvent') |
|
201 | - ->willReturn($event); |
|
202 | - |
|
203 | - $event->expects($this->once()) |
|
204 | - ->method('setApp') |
|
205 | - ->with('dav') |
|
206 | - ->willReturnSelf(); |
|
207 | - $event->expects($this->once()) |
|
208 | - ->method('setObject') |
|
209 | - ->with('calendar', $data['id']) |
|
210 | - ->willReturnSelf(); |
|
211 | - $event->expects($this->once()) |
|
212 | - ->method('setType') |
|
213 | - ->with('calendar') |
|
214 | - ->willReturnSelf(); |
|
215 | - $event->expects($this->once()) |
|
216 | - ->method('setAuthor') |
|
217 | - ->with($author) |
|
218 | - ->willReturnSelf(); |
|
219 | - |
|
220 | - $this->userManager->expects($action === Calendar::SUBJECT_DELETE ? $this->exactly(sizeof($users)) : $this->never()) |
|
221 | - ->method('userExists') |
|
222 | - ->willReturn(true); |
|
223 | - |
|
224 | - $event->expects($this->exactly(sizeof($users))) |
|
225 | - ->method('setAffectedUser') |
|
226 | - ->willReturnSelf(); |
|
227 | - $event->expects($this->exactly(sizeof($users))) |
|
228 | - ->method('setSubject') |
|
229 | - ->willReturnSelf(); |
|
230 | - $this->activityManager->expects($this->exactly(sizeof($users))) |
|
231 | - ->method('publish') |
|
232 | - ->with($event); |
|
233 | - } else { |
|
234 | - $this->activityManager->expects($this->never()) |
|
235 | - ->method('generateEvent'); |
|
236 | - } |
|
237 | - |
|
238 | - $this->invokePrivate($backend, 'triggerCalendarActivity', [$action, $data, $shares, $changedProperties]); |
|
239 | - } |
|
240 | - |
|
241 | - public function testUserDeletionDoesNotCreateActivity(): void { |
|
242 | - $backend = $this->getBackend(); |
|
243 | - |
|
244 | - $this->userManager->expects($this->once()) |
|
245 | - ->method('userExists') |
|
246 | - ->willReturn(false); |
|
247 | - |
|
248 | - $this->activityManager->expects($this->never()) |
|
249 | - ->method('publish'); |
|
250 | - |
|
251 | - $this->invokePrivate($backend, 'triggerCalendarActivity', [Calendar::SUBJECT_DELETE, [ |
|
252 | - 'principaluri' => 'principal/user/admin', |
|
253 | - 'id' => 42, |
|
254 | - 'uri' => 'this-uri', |
|
255 | - '{DAV:}displayname' => 'Name of calendar', |
|
256 | - ], [], []]); |
|
257 | - } |
|
258 | - |
|
259 | - public static function dataGetUsersForShares(): array { |
|
260 | - return [ |
|
261 | - [ |
|
262 | - [], |
|
263 | - [], |
|
264 | - [], |
|
265 | - ], |
|
266 | - [ |
|
267 | - [ |
|
268 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user1'], |
|
269 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
270 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
271 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
272 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user3'], |
|
273 | - ], |
|
274 | - [], |
|
275 | - ['user1', 'user2', 'user3'], |
|
276 | - ], |
|
277 | - [ |
|
278 | - [ |
|
279 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user1'], |
|
280 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
281 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
282 | - ['{http://owncloud.org/ns}principal' => 'principal/groups/group2'], |
|
283 | - ['{http://owncloud.org/ns}principal' => 'principal/groups/group3'], |
|
284 | - ], |
|
285 | - ['group2' => null, 'group3' => null], |
|
286 | - ['user1', 'user2'], |
|
287 | - ], |
|
288 | - [ |
|
289 | - [ |
|
290 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user1'], |
|
291 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
292 | - ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
293 | - ['{http://owncloud.org/ns}principal' => 'principal/groups/group2'], |
|
294 | - ['{http://owncloud.org/ns}principal' => 'principal/groups/group3'], |
|
295 | - ], |
|
296 | - ['group2' => ['user1', 'user2', 'user3'], 'group3' => ['user2', 'user3', 'user4']], |
|
297 | - ['user1', 'user2', 'user3', 'user4'], |
|
298 | - ], |
|
299 | - ]; |
|
300 | - } |
|
301 | - |
|
302 | - /** |
|
303 | - * @dataProvider dataGetUsersForShares |
|
304 | - */ |
|
305 | - public function testGetUsersForShares(array $shares, array $groups, array $expected): void { |
|
306 | - $backend = $this->getBackend(); |
|
307 | - |
|
308 | - $getGroups = []; |
|
309 | - foreach ($groups as $gid => $members) { |
|
310 | - if ($members === null) { |
|
311 | - $getGroups[] = [$gid, null]; |
|
312 | - continue; |
|
313 | - } |
|
314 | - |
|
315 | - $group = $this->createMock(IGroup::class); |
|
316 | - $group->expects($this->once()) |
|
317 | - ->method('getUsers') |
|
318 | - ->willReturn($this->getUsers($members)); |
|
319 | - |
|
320 | - $getGroups[] = [$gid, $group]; |
|
321 | - } |
|
322 | - |
|
323 | - $this->groupManager->expects($this->exactly(sizeof($getGroups))) |
|
324 | - ->method('get') |
|
325 | - ->willReturnMap($getGroups); |
|
326 | - |
|
327 | - $users = $this->invokePrivate($backend, 'getUsersForShares', [$shares]); |
|
328 | - sort($users); |
|
329 | - $this->assertEquals($expected, $users); |
|
330 | - } |
|
331 | - |
|
332 | - /** |
|
333 | - * @param string[] $users |
|
334 | - * @return IUser[]&MockObject[] |
|
335 | - */ |
|
336 | - protected function getUsers(array $users) { |
|
337 | - $list = []; |
|
338 | - foreach ($users as $user) { |
|
339 | - $list[] = $this->getUserMock($user); |
|
340 | - } |
|
341 | - return $list; |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * @param string $uid |
|
346 | - * @return IUser&MockObject |
|
347 | - */ |
|
348 | - protected function getUserMock($uid) { |
|
349 | - $user = $this->createMock(IUser::class); |
|
350 | - $user->expects($this->once()) |
|
351 | - ->method('getUID') |
|
352 | - ->willReturn($uid); |
|
353 | - return $user; |
|
354 | - } |
|
24 | + protected IManager&MockObject $activityManager; |
|
25 | + protected IGroupManager&MockObject $groupManager; |
|
26 | + protected IUserSession&MockObject $userSession; |
|
27 | + protected IAppManager&MockObject $appManager; |
|
28 | + protected IUserManager&MockObject $userManager; |
|
29 | + |
|
30 | + protected function setUp(): void { |
|
31 | + parent::setUp(); |
|
32 | + $this->activityManager = $this->createMock(IManager::class); |
|
33 | + $this->groupManager = $this->createMock(IGroupManager::class); |
|
34 | + $this->userSession = $this->createMock(IUserSession::class); |
|
35 | + $this->appManager = $this->createMock(IAppManager::class); |
|
36 | + $this->userManager = $this->createMock(IUserManager::class); |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * @return Backend|(Backend&MockObject) |
|
41 | + */ |
|
42 | + protected function getBackend(array $methods = []): Backend { |
|
43 | + if (empty($methods)) { |
|
44 | + return new Backend( |
|
45 | + $this->activityManager, |
|
46 | + $this->groupManager, |
|
47 | + $this->userSession, |
|
48 | + $this->appManager, |
|
49 | + $this->userManager |
|
50 | + ); |
|
51 | + } else { |
|
52 | + return $this->getMockBuilder(Backend::class) |
|
53 | + ->setConstructorArgs([ |
|
54 | + $this->activityManager, |
|
55 | + $this->groupManager, |
|
56 | + $this->userSession, |
|
57 | + $this->appManager, |
|
58 | + $this->userManager |
|
59 | + ]) |
|
60 | + ->onlyMethods($methods) |
|
61 | + ->getMock(); |
|
62 | + } |
|
63 | + } |
|
64 | + |
|
65 | + public static function dataCallTriggerCalendarActivity(): array { |
|
66 | + return [ |
|
67 | + ['onCalendarAdd', [['data']], Calendar::SUBJECT_ADD, [['data'], [], []]], |
|
68 | + ['onCalendarUpdate', [['data'], ['shares'], ['changed-properties']], Calendar::SUBJECT_UPDATE, [['data'], ['shares'], ['changed-properties']]], |
|
69 | + ['onCalendarDelete', [['data'], ['shares']], Calendar::SUBJECT_DELETE, [['data'], ['shares'], []]], |
|
70 | + ['onCalendarPublication', [['data'], true], Calendar::SUBJECT_PUBLISH, [['data'], [], []]], |
|
71 | + ]; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @dataProvider dataCallTriggerCalendarActivity |
|
76 | + */ |
|
77 | + public function testCallTriggerCalendarActivity(string $method, array $payload, string $expectedSubject, array $expectedPayload): void { |
|
78 | + $backend = $this->getBackend(['triggerCalendarActivity']); |
|
79 | + $backend->expects($this->once()) |
|
80 | + ->method('triggerCalendarActivity') |
|
81 | + ->willReturnCallback(function () use ($expectedPayload, $expectedSubject): void { |
|
82 | + $arguments = func_get_args(); |
|
83 | + $this->assertSame($expectedSubject, array_shift($arguments)); |
|
84 | + $this->assertEquals($expectedPayload, $arguments); |
|
85 | + }); |
|
86 | + |
|
87 | + call_user_func_array([$backend, $method], $payload); |
|
88 | + } |
|
89 | + |
|
90 | + public static function dataTriggerCalendarActivity(): array { |
|
91 | + return [ |
|
92 | + // Add calendar |
|
93 | + [Calendar::SUBJECT_ADD, [], [], [], '', '', null, []], |
|
94 | + [Calendar::SUBJECT_ADD, [ |
|
95 | + 'principaluri' => 'principal/user/admin', |
|
96 | + 'id' => 42, |
|
97 | + 'uri' => 'this-uri', |
|
98 | + '{DAV:}displayname' => 'Name of calendar', |
|
99 | + ], [], [], '', 'admin', null, ['admin']], |
|
100 | + [Calendar::SUBJECT_ADD, [ |
|
101 | + 'principaluri' => 'principal/user/admin', |
|
102 | + 'id' => 42, |
|
103 | + 'uri' => 'this-uri', |
|
104 | + '{DAV:}displayname' => 'Name of calendar', |
|
105 | + ], [], [], 'test2', 'test2', null, ['admin']], |
|
106 | + |
|
107 | + // Update calendar |
|
108 | + [Calendar::SUBJECT_UPDATE, [], [], [], '', '', null, []], |
|
109 | + // No visible change - owner only |
|
110 | + [Calendar::SUBJECT_UPDATE, [ |
|
111 | + 'principaluri' => 'principal/user/admin', |
|
112 | + 'id' => 42, |
|
113 | + 'uri' => 'this-uri', |
|
114 | + '{DAV:}displayname' => 'Name of calendar', |
|
115 | + ], ['shares'], [], '', 'admin', null, ['admin']], |
|
116 | + // Visible change |
|
117 | + [Calendar::SUBJECT_UPDATE, [ |
|
118 | + 'principaluri' => 'principal/user/admin', |
|
119 | + 'id' => 42, |
|
120 | + 'uri' => 'this-uri', |
|
121 | + '{DAV:}displayname' => 'Name of calendar', |
|
122 | + ], ['shares'], ['{DAV:}displayname' => 'Name'], '', 'admin', ['user1'], ['user1', 'admin']], |
|
123 | + [Calendar::SUBJECT_UPDATE, [ |
|
124 | + 'principaluri' => 'principal/user/admin', |
|
125 | + 'id' => 42, |
|
126 | + 'uri' => 'this-uri', |
|
127 | + '{DAV:}displayname' => 'Name of calendar', |
|
128 | + ], ['shares'], ['{DAV:}displayname' => 'Name'], 'test2', 'test2', ['user1'], ['user1', 'admin']], |
|
129 | + |
|
130 | + // Delete calendar |
|
131 | + [Calendar::SUBJECT_DELETE, [], [], [], '', '', null, []], |
|
132 | + [Calendar::SUBJECT_DELETE, [ |
|
133 | + 'principaluri' => 'principal/user/admin', |
|
134 | + 'id' => 42, |
|
135 | + 'uri' => 'this-uri', |
|
136 | + '{DAV:}displayname' => 'Name of calendar', |
|
137 | + ], ['shares'], [], '', 'admin', [], ['admin']], |
|
138 | + [Calendar::SUBJECT_DELETE, [ |
|
139 | + 'principaluri' => 'principal/user/admin', |
|
140 | + 'id' => 42, |
|
141 | + 'uri' => 'this-uri', |
|
142 | + '{DAV:}displayname' => 'Name of calendar', |
|
143 | + ], ['shares'], [], '', 'admin', ['user1'], ['user1', 'admin']], |
|
144 | + [Calendar::SUBJECT_DELETE, [ |
|
145 | + 'principaluri' => 'principal/user/admin', |
|
146 | + 'id' => 42, |
|
147 | + 'uri' => 'this-uri', |
|
148 | + '{DAV:}displayname' => 'Name of calendar', |
|
149 | + ], ['shares'], [], 'test2', 'test2', ['user1'], ['user1', 'admin']], |
|
150 | + |
|
151 | + // Publish calendar |
|
152 | + [Calendar::SUBJECT_PUBLISH, [], [], [], '', '', null, []], |
|
153 | + [Calendar::SUBJECT_PUBLISH, [ |
|
154 | + 'principaluri' => 'principal/user/admin', |
|
155 | + 'id' => 42, |
|
156 | + 'uri' => 'this-uri', |
|
157 | + '{DAV:}displayname' => 'Name of calendar', |
|
158 | + ], ['shares'], [], '', 'admin', [], ['admin']], |
|
159 | + |
|
160 | + // Unpublish calendar |
|
161 | + [Calendar::SUBJECT_UNPUBLISH, [], [], [], '', '', null, []], |
|
162 | + [Calendar::SUBJECT_UNPUBLISH, [ |
|
163 | + 'principaluri' => 'principal/user/admin', |
|
164 | + 'id' => 42, |
|
165 | + 'uri' => 'this-uri', |
|
166 | + '{DAV:}displayname' => 'Name of calendar', |
|
167 | + ], ['shares'], [], '', 'admin', [], ['admin']], |
|
168 | + ]; |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * @dataProvider dataTriggerCalendarActivity |
|
173 | + */ |
|
174 | + public function testTriggerCalendarActivity(string $action, array $data, array $shares, array $changedProperties, string $currentUser, string $author, ?array $shareUsers, array $users): void { |
|
175 | + $backend = $this->getBackend(['getUsersForShares']); |
|
176 | + |
|
177 | + if ($shareUsers === null) { |
|
178 | + $backend->expects($this->never()) |
|
179 | + ->method('getUsersForShares'); |
|
180 | + } else { |
|
181 | + $backend->expects($this->once()) |
|
182 | + ->method('getUsersForShares') |
|
183 | + ->with($shares) |
|
184 | + ->willReturn($shareUsers); |
|
185 | + } |
|
186 | + |
|
187 | + if ($author !== '') { |
|
188 | + if ($currentUser !== '') { |
|
189 | + $this->userSession->expects($this->once()) |
|
190 | + ->method('getUser') |
|
191 | + ->willReturn($this->getUserMock($currentUser)); |
|
192 | + } else { |
|
193 | + $this->userSession->expects($this->once()) |
|
194 | + ->method('getUser') |
|
195 | + ->willReturn(null); |
|
196 | + } |
|
197 | + |
|
198 | + $event = $this->createMock(IEvent::class); |
|
199 | + $this->activityManager->expects($this->once()) |
|
200 | + ->method('generateEvent') |
|
201 | + ->willReturn($event); |
|
202 | + |
|
203 | + $event->expects($this->once()) |
|
204 | + ->method('setApp') |
|
205 | + ->with('dav') |
|
206 | + ->willReturnSelf(); |
|
207 | + $event->expects($this->once()) |
|
208 | + ->method('setObject') |
|
209 | + ->with('calendar', $data['id']) |
|
210 | + ->willReturnSelf(); |
|
211 | + $event->expects($this->once()) |
|
212 | + ->method('setType') |
|
213 | + ->with('calendar') |
|
214 | + ->willReturnSelf(); |
|
215 | + $event->expects($this->once()) |
|
216 | + ->method('setAuthor') |
|
217 | + ->with($author) |
|
218 | + ->willReturnSelf(); |
|
219 | + |
|
220 | + $this->userManager->expects($action === Calendar::SUBJECT_DELETE ? $this->exactly(sizeof($users)) : $this->never()) |
|
221 | + ->method('userExists') |
|
222 | + ->willReturn(true); |
|
223 | + |
|
224 | + $event->expects($this->exactly(sizeof($users))) |
|
225 | + ->method('setAffectedUser') |
|
226 | + ->willReturnSelf(); |
|
227 | + $event->expects($this->exactly(sizeof($users))) |
|
228 | + ->method('setSubject') |
|
229 | + ->willReturnSelf(); |
|
230 | + $this->activityManager->expects($this->exactly(sizeof($users))) |
|
231 | + ->method('publish') |
|
232 | + ->with($event); |
|
233 | + } else { |
|
234 | + $this->activityManager->expects($this->never()) |
|
235 | + ->method('generateEvent'); |
|
236 | + } |
|
237 | + |
|
238 | + $this->invokePrivate($backend, 'triggerCalendarActivity', [$action, $data, $shares, $changedProperties]); |
|
239 | + } |
|
240 | + |
|
241 | + public function testUserDeletionDoesNotCreateActivity(): void { |
|
242 | + $backend = $this->getBackend(); |
|
243 | + |
|
244 | + $this->userManager->expects($this->once()) |
|
245 | + ->method('userExists') |
|
246 | + ->willReturn(false); |
|
247 | + |
|
248 | + $this->activityManager->expects($this->never()) |
|
249 | + ->method('publish'); |
|
250 | + |
|
251 | + $this->invokePrivate($backend, 'triggerCalendarActivity', [Calendar::SUBJECT_DELETE, [ |
|
252 | + 'principaluri' => 'principal/user/admin', |
|
253 | + 'id' => 42, |
|
254 | + 'uri' => 'this-uri', |
|
255 | + '{DAV:}displayname' => 'Name of calendar', |
|
256 | + ], [], []]); |
|
257 | + } |
|
258 | + |
|
259 | + public static function dataGetUsersForShares(): array { |
|
260 | + return [ |
|
261 | + [ |
|
262 | + [], |
|
263 | + [], |
|
264 | + [], |
|
265 | + ], |
|
266 | + [ |
|
267 | + [ |
|
268 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user1'], |
|
269 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
270 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
271 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
272 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user3'], |
|
273 | + ], |
|
274 | + [], |
|
275 | + ['user1', 'user2', 'user3'], |
|
276 | + ], |
|
277 | + [ |
|
278 | + [ |
|
279 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user1'], |
|
280 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
281 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
282 | + ['{http://owncloud.org/ns}principal' => 'principal/groups/group2'], |
|
283 | + ['{http://owncloud.org/ns}principal' => 'principal/groups/group3'], |
|
284 | + ], |
|
285 | + ['group2' => null, 'group3' => null], |
|
286 | + ['user1', 'user2'], |
|
287 | + ], |
|
288 | + [ |
|
289 | + [ |
|
290 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user1'], |
|
291 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
292 | + ['{http://owncloud.org/ns}principal' => 'principal/users/user2'], |
|
293 | + ['{http://owncloud.org/ns}principal' => 'principal/groups/group2'], |
|
294 | + ['{http://owncloud.org/ns}principal' => 'principal/groups/group3'], |
|
295 | + ], |
|
296 | + ['group2' => ['user1', 'user2', 'user3'], 'group3' => ['user2', 'user3', 'user4']], |
|
297 | + ['user1', 'user2', 'user3', 'user4'], |
|
298 | + ], |
|
299 | + ]; |
|
300 | + } |
|
301 | + |
|
302 | + /** |
|
303 | + * @dataProvider dataGetUsersForShares |
|
304 | + */ |
|
305 | + public function testGetUsersForShares(array $shares, array $groups, array $expected): void { |
|
306 | + $backend = $this->getBackend(); |
|
307 | + |
|
308 | + $getGroups = []; |
|
309 | + foreach ($groups as $gid => $members) { |
|
310 | + if ($members === null) { |
|
311 | + $getGroups[] = [$gid, null]; |
|
312 | + continue; |
|
313 | + } |
|
314 | + |
|
315 | + $group = $this->createMock(IGroup::class); |
|
316 | + $group->expects($this->once()) |
|
317 | + ->method('getUsers') |
|
318 | + ->willReturn($this->getUsers($members)); |
|
319 | + |
|
320 | + $getGroups[] = [$gid, $group]; |
|
321 | + } |
|
322 | + |
|
323 | + $this->groupManager->expects($this->exactly(sizeof($getGroups))) |
|
324 | + ->method('get') |
|
325 | + ->willReturnMap($getGroups); |
|
326 | + |
|
327 | + $users = $this->invokePrivate($backend, 'getUsersForShares', [$shares]); |
|
328 | + sort($users); |
|
329 | + $this->assertEquals($expected, $users); |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * @param string[] $users |
|
334 | + * @return IUser[]&MockObject[] |
|
335 | + */ |
|
336 | + protected function getUsers(array $users) { |
|
337 | + $list = []; |
|
338 | + foreach ($users as $user) { |
|
339 | + $list[] = $this->getUserMock($user); |
|
340 | + } |
|
341 | + return $list; |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * @param string $uid |
|
346 | + * @return IUser&MockObject |
|
347 | + */ |
|
348 | + protected function getUserMock($uid) { |
|
349 | + $user = $this->createMock(IUser::class); |
|
350 | + $user->expects($this->once()) |
|
351 | + ->method('getUID') |
|
352 | + ->willReturn($uid); |
|
353 | + return $user; |
|
354 | + } |
|
355 | 355 | } |
@@ -16,66 +16,66 @@ |
||
16 | 16 | use Sabre\VObject\Component\VCalendar; |
17 | 17 | |
18 | 18 | class ExportServiceTest extends \Test\TestCase { |
19 | - private ServerVersion&MockObject $serverVersion; |
|
20 | - private ExportService $service; |
|
21 | - private ICalendarExport&MockObject $calendar; |
|
22 | - private array $mockExportCollection; |
|
19 | + private ServerVersion&MockObject $serverVersion; |
|
20 | + private ExportService $service; |
|
21 | + private ICalendarExport&MockObject $calendar; |
|
22 | + private array $mockExportCollection; |
|
23 | 23 | |
24 | - protected function setUp(): void { |
|
25 | - parent::setUp(); |
|
24 | + protected function setUp(): void { |
|
25 | + parent::setUp(); |
|
26 | 26 | |
27 | - $this->serverVersion = $this->createMock(ServerVersion::class); |
|
28 | - $this->serverVersion->method('getVersionString') |
|
29 | - ->willReturn('32.0.0.0'); |
|
30 | - $this->service = new ExportService($this->serverVersion); |
|
31 | - $this->calendar = $this->createMock(ICalendarExport::class); |
|
27 | + $this->serverVersion = $this->createMock(ServerVersion::class); |
|
28 | + $this->serverVersion->method('getVersionString') |
|
29 | + ->willReturn('32.0.0.0'); |
|
30 | + $this->service = new ExportService($this->serverVersion); |
|
31 | + $this->calendar = $this->createMock(ICalendarExport::class); |
|
32 | 32 | |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | - protected function mockGenerator(): Generator { |
|
36 | - foreach ($this->mockExportCollection as $entry) { |
|
37 | - yield $entry; |
|
38 | - } |
|
39 | - } |
|
35 | + protected function mockGenerator(): Generator { |
|
36 | + foreach ($this->mockExportCollection as $entry) { |
|
37 | + yield $entry; |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - public function testExport(): void { |
|
42 | - // Arrange |
|
43 | - // construct calendar with a 1 hour event and same start/end time zones |
|
44 | - $vCalendar = new VCalendar(); |
|
45 | - /** @var \Sabre\VObject\Component\VEvent $vEvent */ |
|
46 | - $vEvent = $vCalendar->add('VEVENT', []); |
|
47 | - $vEvent->UID->setValue('96a0e6b1-d886-4a55-a60d-152b31401dcc'); |
|
48 | - $vEvent->add('DTSTART', '20240701T080000', ['TZID' => 'America/Toronto']); |
|
49 | - $vEvent->add('DTEND', '20240701T090000', ['TZID' => 'America/Toronto']); |
|
50 | - $vEvent->add('SUMMARY', 'Test Recurrence Event'); |
|
51 | - $vEvent->add('ORGANIZER', 'mailto:[email protected]', ['CN' => 'Organizer']); |
|
52 | - $vEvent->add('ATTENDEE', 'mailto:[email protected]', [ |
|
53 | - 'CN' => 'Attendee One', |
|
54 | - 'CUTYPE' => 'INDIVIDUAL', |
|
55 | - 'PARTSTAT' => 'NEEDS-ACTION', |
|
56 | - 'ROLE' => 'REQ-PARTICIPANT', |
|
57 | - 'RSVP' => 'TRUE' |
|
58 | - ]); |
|
59 | - // construct calendar return |
|
60 | - $options = new CalendarExportOptions(); |
|
61 | - $this->mockExportCollection[] = $vCalendar; |
|
62 | - $this->calendar->expects($this->once()) |
|
63 | - ->method('export') |
|
64 | - ->with($options) |
|
65 | - ->willReturn($this->mockGenerator()); |
|
41 | + public function testExport(): void { |
|
42 | + // Arrange |
|
43 | + // construct calendar with a 1 hour event and same start/end time zones |
|
44 | + $vCalendar = new VCalendar(); |
|
45 | + /** @var \Sabre\VObject\Component\VEvent $vEvent */ |
|
46 | + $vEvent = $vCalendar->add('VEVENT', []); |
|
47 | + $vEvent->UID->setValue('96a0e6b1-d886-4a55-a60d-152b31401dcc'); |
|
48 | + $vEvent->add('DTSTART', '20240701T080000', ['TZID' => 'America/Toronto']); |
|
49 | + $vEvent->add('DTEND', '20240701T090000', ['TZID' => 'America/Toronto']); |
|
50 | + $vEvent->add('SUMMARY', 'Test Recurrence Event'); |
|
51 | + $vEvent->add('ORGANIZER', 'mailto:[email protected]', ['CN' => 'Organizer']); |
|
52 | + $vEvent->add('ATTENDEE', 'mailto:[email protected]', [ |
|
53 | + 'CN' => 'Attendee One', |
|
54 | + 'CUTYPE' => 'INDIVIDUAL', |
|
55 | + 'PARTSTAT' => 'NEEDS-ACTION', |
|
56 | + 'ROLE' => 'REQ-PARTICIPANT', |
|
57 | + 'RSVP' => 'TRUE' |
|
58 | + ]); |
|
59 | + // construct calendar return |
|
60 | + $options = new CalendarExportOptions(); |
|
61 | + $this->mockExportCollection[] = $vCalendar; |
|
62 | + $this->calendar->expects($this->once()) |
|
63 | + ->method('export') |
|
64 | + ->with($options) |
|
65 | + ->willReturn($this->mockGenerator()); |
|
66 | 66 | |
67 | - // Act |
|
68 | - $document = ''; |
|
69 | - foreach ($this->service->export($this->calendar, $options) as $chunk) { |
|
70 | - $document .= $chunk; |
|
71 | - } |
|
67 | + // Act |
|
68 | + $document = ''; |
|
69 | + foreach ($this->service->export($this->calendar, $options) as $chunk) { |
|
70 | + $document .= $chunk; |
|
71 | + } |
|
72 | 72 | |
73 | - // Assert |
|
74 | - $this->assertStringContainsString('BEGIN:VCALENDAR', $document, 'Exported document calendar start missing'); |
|
75 | - $this->assertStringContainsString('BEGIN:VEVENT', $document, 'Exported document event start missing'); |
|
76 | - $this->assertStringContainsString('END:VEVENT', $document, 'Exported document event end missing'); |
|
77 | - $this->assertStringContainsString('END:VCALENDAR', $document, 'Exported document calendar end missing'); |
|
73 | + // Assert |
|
74 | + $this->assertStringContainsString('BEGIN:VCALENDAR', $document, 'Exported document calendar start missing'); |
|
75 | + $this->assertStringContainsString('BEGIN:VEVENT', $document, 'Exported document event start missing'); |
|
76 | + $this->assertStringContainsString('END:VEVENT', $document, 'Exported document event end missing'); |
|
77 | + $this->assertStringContainsString('END:VCALENDAR', $document, 'Exported document calendar end missing'); |
|
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | } |
@@ -17,104 +17,104 @@ |
||
17 | 17 | use function rewind; |
18 | 18 | |
19 | 19 | class AppCalendarTest extends TestCase { |
20 | - private string $principal = 'principals/users/foo'; |
|
21 | - |
|
22 | - private AppCalendar $appCalendar; |
|
23 | - private AppCalendar $writeableAppCalendar; |
|
24 | - |
|
25 | - private ICalendar&MockObject $calendar; |
|
26 | - private ICalendar&MockObject $writeableCalendar; |
|
27 | - |
|
28 | - protected function setUp(): void { |
|
29 | - parent::setUp(); |
|
30 | - |
|
31 | - $this->calendar = $this->getMockBuilder(ICalendar::class)->getMock(); |
|
32 | - $this->calendar->method('getPermissions') |
|
33 | - ->willReturn(Constants::PERMISSION_READ); |
|
34 | - |
|
35 | - $this->writeableCalendar = $this->getMockBuilder(ICreateFromString::class)->getMock(); |
|
36 | - $this->writeableCalendar->method('getPermissions') |
|
37 | - ->willReturn(Constants::PERMISSION_READ | Constants::PERMISSION_CREATE); |
|
38 | - |
|
39 | - $this->appCalendar = new AppCalendar('dav-wrapper', $this->calendar, $this->principal); |
|
40 | - $this->writeableAppCalendar = new AppCalendar('dav-wrapper', $this->writeableCalendar, $this->principal); |
|
41 | - } |
|
42 | - |
|
43 | - public function testGetPrincipal():void { |
|
44 | - // Check that the correct name is returned |
|
45 | - $this->assertEquals($this->principal, $this->appCalendar->getOwner()); |
|
46 | - $this->assertEquals($this->principal, $this->writeableAppCalendar->getOwner()); |
|
47 | - } |
|
48 | - |
|
49 | - public function testDelete(): void { |
|
50 | - $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
51 | - $this->expectExceptionMessage('Deleting an entry is not implemented'); |
|
52 | - |
|
53 | - $this->appCalendar->delete(); |
|
54 | - } |
|
55 | - |
|
56 | - public function testCreateFile(): void { |
|
57 | - $calls = [ |
|
58 | - ['some-name', 'data'], |
|
59 | - ['other-name', ''], |
|
60 | - ['name', 'some data'], |
|
61 | - ]; |
|
62 | - $this->writeableCalendar->expects($this->exactly(3)) |
|
63 | - ->method('createFromString') |
|
64 | - ->willReturnCallback(function () use (&$calls) { |
|
65 | - $expected = array_shift($calls); |
|
66 | - $this->assertEquals($expected, func_get_args()); |
|
67 | - }); |
|
68 | - |
|
69 | - // pass data |
|
70 | - $this->assertNull($this->writeableAppCalendar->createFile('some-name', 'data')); |
|
71 | - // null is empty string |
|
72 | - $this->assertNull($this->writeableAppCalendar->createFile('other-name', null)); |
|
73 | - // resource to data |
|
74 | - $fp = fopen('php://memory', 'r+'); |
|
75 | - fwrite($fp, 'some data'); |
|
76 | - rewind($fp); |
|
77 | - $this->assertNull($this->writeableAppCalendar->createFile('name', $fp)); |
|
78 | - fclose($fp); |
|
79 | - } |
|
80 | - |
|
81 | - public function testCreateFile_readOnly(): void { |
|
82 | - // If writing is not supported |
|
83 | - $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
84 | - $this->expectExceptionMessage('Creating a new entry is not allowed'); |
|
85 | - |
|
86 | - $this->appCalendar->createFile('some-name', 'data'); |
|
87 | - } |
|
88 | - |
|
89 | - public function testSetACL(): void { |
|
90 | - $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
91 | - $this->expectExceptionMessage('Setting ACL is not supported on this node'); |
|
92 | - |
|
93 | - $this->appCalendar->setACL([]); |
|
94 | - } |
|
95 | - |
|
96 | - public function testGetACL():void { |
|
97 | - $expectedRO = [ |
|
98 | - [ |
|
99 | - 'privilege' => '{DAV:}read', |
|
100 | - 'principal' => $this->principal, |
|
101 | - 'protected' => true, |
|
102 | - ], |
|
103 | - [ |
|
104 | - 'privilege' => '{DAV:}write-properties', |
|
105 | - 'principal' => $this->principal, |
|
106 | - 'protected' => true, |
|
107 | - ] |
|
108 | - ]; |
|
109 | - $expectedRW = $expectedRO; |
|
110 | - $expectedRW[] = [ |
|
111 | - 'privilege' => '{DAV:}write', |
|
112 | - 'principal' => $this->principal, |
|
113 | - 'protected' => true, |
|
114 | - ]; |
|
115 | - |
|
116 | - // Check that the correct ACL is returned (default be only readable) |
|
117 | - $this->assertEquals($expectedRO, $this->appCalendar->getACL()); |
|
118 | - $this->assertEquals($expectedRW, $this->writeableAppCalendar->getACL()); |
|
119 | - } |
|
20 | + private string $principal = 'principals/users/foo'; |
|
21 | + |
|
22 | + private AppCalendar $appCalendar; |
|
23 | + private AppCalendar $writeableAppCalendar; |
|
24 | + |
|
25 | + private ICalendar&MockObject $calendar; |
|
26 | + private ICalendar&MockObject $writeableCalendar; |
|
27 | + |
|
28 | + protected function setUp(): void { |
|
29 | + parent::setUp(); |
|
30 | + |
|
31 | + $this->calendar = $this->getMockBuilder(ICalendar::class)->getMock(); |
|
32 | + $this->calendar->method('getPermissions') |
|
33 | + ->willReturn(Constants::PERMISSION_READ); |
|
34 | + |
|
35 | + $this->writeableCalendar = $this->getMockBuilder(ICreateFromString::class)->getMock(); |
|
36 | + $this->writeableCalendar->method('getPermissions') |
|
37 | + ->willReturn(Constants::PERMISSION_READ | Constants::PERMISSION_CREATE); |
|
38 | + |
|
39 | + $this->appCalendar = new AppCalendar('dav-wrapper', $this->calendar, $this->principal); |
|
40 | + $this->writeableAppCalendar = new AppCalendar('dav-wrapper', $this->writeableCalendar, $this->principal); |
|
41 | + } |
|
42 | + |
|
43 | + public function testGetPrincipal():void { |
|
44 | + // Check that the correct name is returned |
|
45 | + $this->assertEquals($this->principal, $this->appCalendar->getOwner()); |
|
46 | + $this->assertEquals($this->principal, $this->writeableAppCalendar->getOwner()); |
|
47 | + } |
|
48 | + |
|
49 | + public function testDelete(): void { |
|
50 | + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
51 | + $this->expectExceptionMessage('Deleting an entry is not implemented'); |
|
52 | + |
|
53 | + $this->appCalendar->delete(); |
|
54 | + } |
|
55 | + |
|
56 | + public function testCreateFile(): void { |
|
57 | + $calls = [ |
|
58 | + ['some-name', 'data'], |
|
59 | + ['other-name', ''], |
|
60 | + ['name', 'some data'], |
|
61 | + ]; |
|
62 | + $this->writeableCalendar->expects($this->exactly(3)) |
|
63 | + ->method('createFromString') |
|
64 | + ->willReturnCallback(function () use (&$calls) { |
|
65 | + $expected = array_shift($calls); |
|
66 | + $this->assertEquals($expected, func_get_args()); |
|
67 | + }); |
|
68 | + |
|
69 | + // pass data |
|
70 | + $this->assertNull($this->writeableAppCalendar->createFile('some-name', 'data')); |
|
71 | + // null is empty string |
|
72 | + $this->assertNull($this->writeableAppCalendar->createFile('other-name', null)); |
|
73 | + // resource to data |
|
74 | + $fp = fopen('php://memory', 'r+'); |
|
75 | + fwrite($fp, 'some data'); |
|
76 | + rewind($fp); |
|
77 | + $this->assertNull($this->writeableAppCalendar->createFile('name', $fp)); |
|
78 | + fclose($fp); |
|
79 | + } |
|
80 | + |
|
81 | + public function testCreateFile_readOnly(): void { |
|
82 | + // If writing is not supported |
|
83 | + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
84 | + $this->expectExceptionMessage('Creating a new entry is not allowed'); |
|
85 | + |
|
86 | + $this->appCalendar->createFile('some-name', 'data'); |
|
87 | + } |
|
88 | + |
|
89 | + public function testSetACL(): void { |
|
90 | + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
91 | + $this->expectExceptionMessage('Setting ACL is not supported on this node'); |
|
92 | + |
|
93 | + $this->appCalendar->setACL([]); |
|
94 | + } |
|
95 | + |
|
96 | + public function testGetACL():void { |
|
97 | + $expectedRO = [ |
|
98 | + [ |
|
99 | + 'privilege' => '{DAV:}read', |
|
100 | + 'principal' => $this->principal, |
|
101 | + 'protected' => true, |
|
102 | + ], |
|
103 | + [ |
|
104 | + 'privilege' => '{DAV:}write-properties', |
|
105 | + 'principal' => $this->principal, |
|
106 | + 'protected' => true, |
|
107 | + ] |
|
108 | + ]; |
|
109 | + $expectedRW = $expectedRO; |
|
110 | + $expectedRW[] = [ |
|
111 | + 'privilege' => '{DAV:}write', |
|
112 | + 'principal' => $this->principal, |
|
113 | + 'protected' => true, |
|
114 | + ]; |
|
115 | + |
|
116 | + // Check that the correct ACL is returned (default be only readable) |
|
117 | + $this->assertEquals($expectedRO, $this->appCalendar->getACL()); |
|
118 | + $this->assertEquals($expectedRW, $this->writeableAppCalendar->getACL()); |
|
119 | + } |
|
120 | 120 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | ]; |
62 | 62 | $this->writeableCalendar->expects($this->exactly(3)) |
63 | 63 | ->method('createFromString') |
64 | - ->willReturnCallback(function () use (&$calls) { |
|
64 | + ->willReturnCallback(function() use (&$calls) { |
|
65 | 65 | $expected = array_shift($calls); |
66 | 66 | $this->assertEquals($expected, func_get_args()); |
67 | 67 | }); |
@@ -17,154 +17,154 @@ |
||
17 | 17 | use Test\TestCase; |
18 | 18 | |
19 | 19 | class CalendarObjectTest extends TestCase { |
20 | - private CalendarObject $calendarObject; |
|
21 | - private AppCalendar&MockObject $calendar; |
|
22 | - private ICalendar&MockObject $backend; |
|
23 | - private VCalendar&MockObject $vobject; |
|
24 | - |
|
25 | - protected function setUp(): void { |
|
26 | - parent::setUp(); |
|
27 | - |
|
28 | - $this->calendar = $this->createMock(AppCalendar::class); |
|
29 | - $this->calendar->method('getOwner')->willReturn('owner'); |
|
30 | - $this->calendar->method('getGroup')->willReturn('group'); |
|
31 | - |
|
32 | - $this->backend = $this->createMock(ICalendar::class); |
|
33 | - $this->vobject = $this->createMock(VCalendar::class); |
|
34 | - $this->calendarObject = new CalendarObject($this->calendar, $this->backend, $this->vobject); |
|
35 | - } |
|
36 | - |
|
37 | - public function testGetOwner(): void { |
|
38 | - $this->assertEquals($this->calendarObject->getOwner(), 'owner'); |
|
39 | - } |
|
40 | - |
|
41 | - public function testGetGroup(): void { |
|
42 | - $this->assertEquals($this->calendarObject->getGroup(), 'group'); |
|
43 | - } |
|
44 | - |
|
45 | - public function testGetACL(): void { |
|
46 | - $this->calendar->expects($this->exactly(2)) |
|
47 | - ->method('getPermissions') |
|
48 | - ->willReturnOnConsecutiveCalls(Constants::PERMISSION_READ, Constants::PERMISSION_ALL); |
|
49 | - |
|
50 | - // read only |
|
51 | - $this->assertEquals($this->calendarObject->getACL(), [ |
|
52 | - [ |
|
53 | - 'privilege' => '{DAV:}read', |
|
54 | - 'principal' => 'owner', |
|
55 | - 'protected' => true, |
|
56 | - ] |
|
57 | - ]); |
|
58 | - |
|
59 | - // write permissions |
|
60 | - $this->assertEquals($this->calendarObject->getACL(), [ |
|
61 | - [ |
|
62 | - 'privilege' => '{DAV:}read', |
|
63 | - 'principal' => 'owner', |
|
64 | - 'protected' => true, |
|
65 | - ], |
|
66 | - [ |
|
67 | - 'privilege' => '{DAV:}write-content', |
|
68 | - 'principal' => 'owner', |
|
69 | - 'protected' => true, |
|
70 | - ] |
|
71 | - ]); |
|
72 | - } |
|
73 | - |
|
74 | - public function testSetACL(): void { |
|
75 | - $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
76 | - $this->calendarObject->setACL([]); |
|
77 | - } |
|
78 | - |
|
79 | - public function testPut_readOnlyBackend(): void { |
|
80 | - $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
81 | - $this->calendarObject->put('foo'); |
|
82 | - } |
|
83 | - |
|
84 | - public function testPut_noPermissions(): void { |
|
85 | - $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
86 | - |
|
87 | - $backend = $this->createMock(ICreateFromString::class); |
|
88 | - $calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject); |
|
89 | - |
|
90 | - $this->calendar->expects($this->once()) |
|
91 | - ->method('getPermissions') |
|
92 | - ->willReturn(Constants::PERMISSION_READ); |
|
93 | - |
|
94 | - $calendarObject->put('foo'); |
|
95 | - } |
|
96 | - |
|
97 | - public function testPut(): void { |
|
98 | - $backend = $this->createMock(ICreateFromString::class); |
|
99 | - $calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject); |
|
100 | - |
|
101 | - $this->vobject->expects($this->once()) |
|
102 | - ->method('getBaseComponent') |
|
103 | - ->willReturn((object)['UID' => 'someid']); |
|
104 | - $this->calendar->expects($this->once()) |
|
105 | - ->method('getPermissions') |
|
106 | - ->willReturn(Constants::PERMISSION_ALL); |
|
107 | - |
|
108 | - $backend->expects($this->once()) |
|
109 | - ->method('createFromString') |
|
110 | - ->with('someid.ics', 'foo'); |
|
111 | - $calendarObject->put('foo'); |
|
112 | - } |
|
113 | - |
|
114 | - public function testGet(): void { |
|
115 | - $this->vobject->expects($this->once()) |
|
116 | - ->method('serialize') |
|
117 | - ->willReturn('foo'); |
|
118 | - $this->assertEquals($this->calendarObject->get(), 'foo'); |
|
119 | - } |
|
120 | - |
|
121 | - public function testDelete_notWriteable(): void { |
|
122 | - $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
123 | - $this->calendarObject->delete(); |
|
124 | - } |
|
125 | - |
|
126 | - public function testDelete_noPermission(): void { |
|
127 | - $backend = $this->createMock(ICreateFromString::class); |
|
128 | - $calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject); |
|
129 | - |
|
130 | - $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
131 | - $calendarObject->delete(); |
|
132 | - } |
|
133 | - |
|
134 | - public function testDelete(): void { |
|
135 | - $backend = $this->createMock(ICreateFromString::class); |
|
136 | - $calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject); |
|
137 | - |
|
138 | - $components = [(new VCalendar(['VEVENT' => ['UID' => 'someid']]))->getBaseComponent()]; |
|
139 | - |
|
140 | - $this->calendar->expects($this->once()) |
|
141 | - ->method('getPermissions') |
|
142 | - ->willReturn(Constants::PERMISSION_DELETE); |
|
143 | - $this->vobject->expects($this->once()) |
|
144 | - ->method('getBaseComponents') |
|
145 | - ->willReturn($components); |
|
146 | - $this->vobject->expects($this->once()) |
|
147 | - ->method('getBaseComponent') |
|
148 | - ->willReturn($components[0]); |
|
149 | - |
|
150 | - $backend->expects($this->once()) |
|
151 | - ->method('createFromString') |
|
152 | - ->with('someid.ics', self::callback(fn ($data): bool => preg_match('/BEGIN:VEVENT(.|\r\n)+STATUS:CANCELLED/', $data) === 1)); |
|
153 | - |
|
154 | - $calendarObject->delete(); |
|
155 | - } |
|
156 | - |
|
157 | - public function testGetName(): void { |
|
158 | - $this->vobject->expects($this->exactly(2)) |
|
159 | - ->method('getBaseComponent') |
|
160 | - ->willReturnOnConsecutiveCalls((object)['UID' => 'someid'], (object)['UID' => 'someid', 'X-FILENAME' => 'real-filename.ics']); |
|
161 | - |
|
162 | - $this->assertEquals($this->calendarObject->getName(), 'someid.ics'); |
|
163 | - $this->assertEquals($this->calendarObject->getName(), 'real-filename.ics'); |
|
164 | - } |
|
165 | - |
|
166 | - public function testSetName(): void { |
|
167 | - $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
168 | - $this->calendarObject->setName('Some name'); |
|
169 | - } |
|
20 | + private CalendarObject $calendarObject; |
|
21 | + private AppCalendar&MockObject $calendar; |
|
22 | + private ICalendar&MockObject $backend; |
|
23 | + private VCalendar&MockObject $vobject; |
|
24 | + |
|
25 | + protected function setUp(): void { |
|
26 | + parent::setUp(); |
|
27 | + |
|
28 | + $this->calendar = $this->createMock(AppCalendar::class); |
|
29 | + $this->calendar->method('getOwner')->willReturn('owner'); |
|
30 | + $this->calendar->method('getGroup')->willReturn('group'); |
|
31 | + |
|
32 | + $this->backend = $this->createMock(ICalendar::class); |
|
33 | + $this->vobject = $this->createMock(VCalendar::class); |
|
34 | + $this->calendarObject = new CalendarObject($this->calendar, $this->backend, $this->vobject); |
|
35 | + } |
|
36 | + |
|
37 | + public function testGetOwner(): void { |
|
38 | + $this->assertEquals($this->calendarObject->getOwner(), 'owner'); |
|
39 | + } |
|
40 | + |
|
41 | + public function testGetGroup(): void { |
|
42 | + $this->assertEquals($this->calendarObject->getGroup(), 'group'); |
|
43 | + } |
|
44 | + |
|
45 | + public function testGetACL(): void { |
|
46 | + $this->calendar->expects($this->exactly(2)) |
|
47 | + ->method('getPermissions') |
|
48 | + ->willReturnOnConsecutiveCalls(Constants::PERMISSION_READ, Constants::PERMISSION_ALL); |
|
49 | + |
|
50 | + // read only |
|
51 | + $this->assertEquals($this->calendarObject->getACL(), [ |
|
52 | + [ |
|
53 | + 'privilege' => '{DAV:}read', |
|
54 | + 'principal' => 'owner', |
|
55 | + 'protected' => true, |
|
56 | + ] |
|
57 | + ]); |
|
58 | + |
|
59 | + // write permissions |
|
60 | + $this->assertEquals($this->calendarObject->getACL(), [ |
|
61 | + [ |
|
62 | + 'privilege' => '{DAV:}read', |
|
63 | + 'principal' => 'owner', |
|
64 | + 'protected' => true, |
|
65 | + ], |
|
66 | + [ |
|
67 | + 'privilege' => '{DAV:}write-content', |
|
68 | + 'principal' => 'owner', |
|
69 | + 'protected' => true, |
|
70 | + ] |
|
71 | + ]); |
|
72 | + } |
|
73 | + |
|
74 | + public function testSetACL(): void { |
|
75 | + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
76 | + $this->calendarObject->setACL([]); |
|
77 | + } |
|
78 | + |
|
79 | + public function testPut_readOnlyBackend(): void { |
|
80 | + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
81 | + $this->calendarObject->put('foo'); |
|
82 | + } |
|
83 | + |
|
84 | + public function testPut_noPermissions(): void { |
|
85 | + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
86 | + |
|
87 | + $backend = $this->createMock(ICreateFromString::class); |
|
88 | + $calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject); |
|
89 | + |
|
90 | + $this->calendar->expects($this->once()) |
|
91 | + ->method('getPermissions') |
|
92 | + ->willReturn(Constants::PERMISSION_READ); |
|
93 | + |
|
94 | + $calendarObject->put('foo'); |
|
95 | + } |
|
96 | + |
|
97 | + public function testPut(): void { |
|
98 | + $backend = $this->createMock(ICreateFromString::class); |
|
99 | + $calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject); |
|
100 | + |
|
101 | + $this->vobject->expects($this->once()) |
|
102 | + ->method('getBaseComponent') |
|
103 | + ->willReturn((object)['UID' => 'someid']); |
|
104 | + $this->calendar->expects($this->once()) |
|
105 | + ->method('getPermissions') |
|
106 | + ->willReturn(Constants::PERMISSION_ALL); |
|
107 | + |
|
108 | + $backend->expects($this->once()) |
|
109 | + ->method('createFromString') |
|
110 | + ->with('someid.ics', 'foo'); |
|
111 | + $calendarObject->put('foo'); |
|
112 | + } |
|
113 | + |
|
114 | + public function testGet(): void { |
|
115 | + $this->vobject->expects($this->once()) |
|
116 | + ->method('serialize') |
|
117 | + ->willReturn('foo'); |
|
118 | + $this->assertEquals($this->calendarObject->get(), 'foo'); |
|
119 | + } |
|
120 | + |
|
121 | + public function testDelete_notWriteable(): void { |
|
122 | + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
123 | + $this->calendarObject->delete(); |
|
124 | + } |
|
125 | + |
|
126 | + public function testDelete_noPermission(): void { |
|
127 | + $backend = $this->createMock(ICreateFromString::class); |
|
128 | + $calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject); |
|
129 | + |
|
130 | + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
131 | + $calendarObject->delete(); |
|
132 | + } |
|
133 | + |
|
134 | + public function testDelete(): void { |
|
135 | + $backend = $this->createMock(ICreateFromString::class); |
|
136 | + $calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject); |
|
137 | + |
|
138 | + $components = [(new VCalendar(['VEVENT' => ['UID' => 'someid']]))->getBaseComponent()]; |
|
139 | + |
|
140 | + $this->calendar->expects($this->once()) |
|
141 | + ->method('getPermissions') |
|
142 | + ->willReturn(Constants::PERMISSION_DELETE); |
|
143 | + $this->vobject->expects($this->once()) |
|
144 | + ->method('getBaseComponents') |
|
145 | + ->willReturn($components); |
|
146 | + $this->vobject->expects($this->once()) |
|
147 | + ->method('getBaseComponent') |
|
148 | + ->willReturn($components[0]); |
|
149 | + |
|
150 | + $backend->expects($this->once()) |
|
151 | + ->method('createFromString') |
|
152 | + ->with('someid.ics', self::callback(fn ($data): bool => preg_match('/BEGIN:VEVENT(.|\r\n)+STATUS:CANCELLED/', $data) === 1)); |
|
153 | + |
|
154 | + $calendarObject->delete(); |
|
155 | + } |
|
156 | + |
|
157 | + public function testGetName(): void { |
|
158 | + $this->vobject->expects($this->exactly(2)) |
|
159 | + ->method('getBaseComponent') |
|
160 | + ->willReturnOnConsecutiveCalls((object)['UID' => 'someid'], (object)['UID' => 'someid', 'X-FILENAME' => 'real-filename.ics']); |
|
161 | + |
|
162 | + $this->assertEquals($this->calendarObject->getName(), 'someid.ics'); |
|
163 | + $this->assertEquals($this->calendarObject->getName(), 'real-filename.ics'); |
|
164 | + } |
|
165 | + |
|
166 | + public function testSetName(): void { |
|
167 | + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |
|
168 | + $this->calendarObject->setName('Some name'); |
|
169 | + } |
|
170 | 170 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | $this->vobject->expects($this->once()) |
102 | 102 | ->method('getBaseComponent') |
103 | - ->willReturn((object)['UID' => 'someid']); |
|
103 | + ->willReturn((object) ['UID' => 'someid']); |
|
104 | 104 | $this->calendar->expects($this->once()) |
105 | 105 | ->method('getPermissions') |
106 | 106 | ->willReturn(Constants::PERMISSION_ALL); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | public function testGetName(): void { |
158 | 158 | $this->vobject->expects($this->exactly(2)) |
159 | 159 | ->method('getBaseComponent') |
160 | - ->willReturnOnConsecutiveCalls((object)['UID' => 'someid'], (object)['UID' => 'someid', 'X-FILENAME' => 'real-filename.ics']); |
|
160 | + ->willReturnOnConsecutiveCalls((object) ['UID' => 'someid'], (object) ['UID' => 'someid', 'X-FILENAME' => 'real-filename.ics']); |
|
161 | 161 | |
162 | 162 | $this->assertEquals($this->calendarObject->getName(), 'someid.ics'); |
163 | 163 | $this->assertEquals($this->calendarObject->getName(), 'real-filename.ics'); |