|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only |
|
5
|
|
|
* SPDX-FileCopyrightText: Copyright 2025 grommunio GmbH |
|
6
|
|
|
* |
|
7
|
|
|
* Unit tests for FreeBusy class |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @internal |
|
14
|
|
|
* |
|
15
|
|
|
* @coversNothing |
|
16
|
|
|
*/ |
|
17
|
|
|
class FreeBusyTest extends TestCase { |
|
18
|
|
|
// Test constants |
|
19
|
|
|
public function testAssociatedFreeBusyFolderConstant(): void { |
|
20
|
|
|
$this->assertEquals(0, FreeBusy::ASSOCIATED_FREEBUSY_FOLDER); |
|
21
|
|
|
$this->assertIsInt(FreeBusy::ASSOCIATED_FREEBUSY_FOLDER); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function testDelegatePropertiesConstant(): void { |
|
25
|
|
|
$this->assertEquals(1, FreeBusy::DELEGATE_PROPERTIES); |
|
26
|
|
|
$this->assertIsInt(FreeBusy::DELEGATE_PROPERTIES); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function testGlobalFreeBusyDataConstant(): void { |
|
30
|
|
|
$this->assertEquals(2, FreeBusy::GLOBAL_FREEBUSYDATA); |
|
31
|
|
|
$this->assertIsInt(FreeBusy::GLOBAL_FREEBUSYDATA); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testFreeBusyDataIpmSubtreeConstant(): void { |
|
35
|
|
|
$this->assertEquals(3, FreeBusy::FREEBUSYDATA_IPM_SUBTREE); |
|
36
|
|
|
$this->assertIsInt(FreeBusy::FREEBUSYDATA_IPM_SUBTREE); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function testAllConstantsAreUnique(): void { |
|
40
|
|
|
$constants = [ |
|
41
|
|
|
FreeBusy::ASSOCIATED_FREEBUSY_FOLDER, |
|
42
|
|
|
FreeBusy::DELEGATE_PROPERTIES, |
|
43
|
|
|
FreeBusy::GLOBAL_FREEBUSYDATA, |
|
44
|
|
|
FreeBusy::FREEBUSYDATA_IPM_SUBTREE, |
|
45
|
|
|
]; |
|
46
|
|
|
|
|
47
|
|
|
$this->assertEquals(4, count(array_unique($constants))); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function testConstantsAreSequential(): void { |
|
51
|
|
|
$this->assertEquals(0, FreeBusy::ASSOCIATED_FREEBUSY_FOLDER); |
|
52
|
|
|
$this->assertEquals(1, FreeBusy::DELEGATE_PROPERTIES); |
|
53
|
|
|
$this->assertEquals(2, FreeBusy::GLOBAL_FREEBUSYDATA); |
|
54
|
|
|
$this->assertEquals(3, FreeBusy::FREEBUSYDATA_IPM_SUBTREE); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function testConstantsMatchDocumentation(): void { |
|
58
|
|
|
// PR_FREEBUSY_ENTRYIDS[0] - associated freebusy folder |
|
59
|
|
|
$this->assertEquals(0, FreeBusy::ASSOCIATED_FREEBUSY_FOLDER); |
|
60
|
|
|
|
|
61
|
|
|
// PR_FREEBUSY_ENTRYIDS[1] - local freebusy (delegate properties) |
|
62
|
|
|
$this->assertEquals(1, FreeBusy::DELEGATE_PROPERTIES); |
|
63
|
|
|
|
|
64
|
|
|
// PR_FREEBUSY_ENTRYIDS[2] - global freebusy data |
|
65
|
|
|
$this->assertEquals(2, FreeBusy::GLOBAL_FREEBUSYDATA); |
|
66
|
|
|
|
|
67
|
|
|
// PR_FREEBUSY_ENTRYIDS[3] - freebusy data in IPM_SUBTREE |
|
68
|
|
|
$this->assertEquals(3, FreeBusy::FREEBUSYDATA_IPM_SUBTREE); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
// Test method signatures and return types |
|
72
|
|
|
public function testGetLocalFreeBusyMessageReturnsFalseWithoutStore(): void { |
|
73
|
|
|
// Note: This test will produce error_log output, which is expected behavior |
|
74
|
|
|
$result = @FreeBusy::getLocalFreeBusyMessage(false); |
|
75
|
|
|
$this->assertFalse($result); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function testGetLocalFreeBusyMessageReturnsFalseWithNull(): void { |
|
79
|
|
|
// Note: This test will produce error_log output, which is expected behavior |
|
80
|
|
|
$result = @FreeBusy::getLocalFreeBusyMessage(null); |
|
81
|
|
|
$this->assertFalse($result); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function testGetLocalFreeBusyFolderReturnsFalseWithoutStore(): void { |
|
85
|
|
|
// Note: This test will produce error_log output, which is expected behavior |
|
86
|
|
|
$result = @FreeBusy::getLocalFreeBusyFolder(false); |
|
87
|
|
|
$this->assertFalse($result); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function testGetLocalFreeBusyFolderReturnsFalseWithNull(): void { |
|
91
|
|
|
// Note: This test will produce error_log output, which is expected behavior |
|
92
|
|
|
$result = @FreeBusy::getLocalFreeBusyFolder(null); |
|
93
|
|
|
$this->assertFalse($result); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function testFreeBusyClassExists(): void { |
|
97
|
|
|
$this->assertTrue(class_exists('FreeBusy')); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function testFreeBusyMethodsAreStatic(): void { |
|
101
|
|
|
$reflection = new ReflectionClass('FreeBusy'); |
|
102
|
|
|
|
|
103
|
|
|
$getLocalFreeBusyMessage = $reflection->getMethod('getLocalFreeBusyMessage'); |
|
104
|
|
|
$this->assertTrue($getLocalFreeBusyMessage->isStatic()); |
|
105
|
|
|
|
|
106
|
|
|
$getLocalFreeBusyFolder = $reflection->getMethod('getLocalFreeBusyFolder'); |
|
107
|
|
|
$this->assertTrue($getLocalFreeBusyFolder->isStatic()); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function testFreeBusyMethodsArePublic(): void { |
|
111
|
|
|
$reflection = new ReflectionClass('FreeBusy'); |
|
112
|
|
|
|
|
113
|
|
|
$getLocalFreeBusyMessage = $reflection->getMethod('getLocalFreeBusyMessage'); |
|
114
|
|
|
$this->assertTrue($getLocalFreeBusyMessage->isPublic()); |
|
115
|
|
|
|
|
116
|
|
|
$getLocalFreeBusyFolder = $reflection->getMethod('getLocalFreeBusyFolder'); |
|
117
|
|
|
$this->assertTrue($getLocalFreeBusyFolder->isPublic()); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
public function testFreeBusyConstantsArePublic(): void { |
|
121
|
|
|
$reflection = new ReflectionClass('FreeBusy'); |
|
122
|
|
|
|
|
123
|
|
|
$this->assertTrue($reflection->hasConstant('ASSOCIATED_FREEBUSY_FOLDER')); |
|
124
|
|
|
$this->assertTrue($reflection->hasConstant('DELEGATE_PROPERTIES')); |
|
125
|
|
|
$this->assertTrue($reflection->hasConstant('GLOBAL_FREEBUSYDATA')); |
|
126
|
|
|
$this->assertTrue($reflection->hasConstant('FREEBUSYDATA_IPM_SUBTREE')); |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths