grommunio /
mapi-header-php
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * SPDX-License-Identifier: AGPL-3.0-only |
||
| 5 | * SPDX-FileCopyrightText: Copyright 2025 grommunio GmbH |
||
| 6 | * |
||
| 7 | * Unit tests for mapi.util.php utility functions |
||
| 8 | */ |
||
| 9 | |||
| 10 | use PHPUnit\Framework\TestCase; |
||
|
0 ignored issues
–
show
|
|||
| 11 | |||
| 12 | /** |
||
| 13 | * @internal |
||
| 14 | * |
||
| 15 | * @coversNothing |
||
| 16 | */ |
||
| 17 | class UtilityFunctionsTest extends TestCase { |
||
| 18 | public function testMakeGuid(): void { |
||
| 19 | $guid = '{00062008-0000-0000-C000-000000000046}'; |
||
| 20 | $result = makeGuid($guid); |
||
| 21 | |||
| 22 | $this->assertIsString($result); |
||
| 23 | $this->assertNotEmpty($result); |
||
| 24 | } |
||
| 25 | |||
| 26 | public function testGetMapiErrorName(): void { |
||
| 27 | // Test with NOERROR |
||
| 28 | $this->assertEquals('NOERROR', get_mapi_error_name(0)); |
||
| 29 | |||
| 30 | // Test with hex string |
||
| 31 | $result = get_mapi_error_name('0x00000000'); |
||
| 32 | $this->assertEquals('NOERROR', $result); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function testCompareEntryIds(): void { |
||
| 36 | // Test with identical strings |
||
| 37 | $this->assertTrue(compareEntryIds('test123', 'test123')); |
||
| 38 | |||
| 39 | // Test with different strings |
||
| 40 | $this->assertFalse(compareEntryIds('test123', 'test456')); |
||
| 41 | |||
| 42 | // Test with non-strings |
||
| 43 | $this->assertFalse(compareEntryIds(123, 'test')); |
||
| 44 | $this->assertFalse(compareEntryIds('test', 123)); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function testGetGoidFromUid(): void { |
||
| 48 | $uid = 'test-calendar-uid-12345'; |
||
| 49 | $result = getGoidFromUid($uid); |
||
| 50 | |||
| 51 | $this->assertIsString($result); |
||
| 52 | $this->assertNotEmpty($result); |
||
| 53 | } |
||
| 54 | |||
| 55 | public function testGetUidFromGoid(): void { |
||
| 56 | // Create a GOID first |
||
| 57 | $uid = 'test-calendar-uid-12345'; |
||
| 58 | $goid = getGoidFromUid($uid); |
||
| 59 | |||
| 60 | // Extract UID back |
||
| 61 | $extracted = getUidFromGoid($goid); |
||
| 62 | $this->assertEquals($uid, $extracted); |
||
| 63 | |||
| 64 | // Test with invalid GOID |
||
| 65 | $this->assertNull(getUidFromGoid('invalid-goid')); |
||
| 66 | } |
||
| 67 | |||
| 68 | public function testProp2Str(): void { |
||
| 69 | // Test with integer (should try to find PR_ constant) |
||
| 70 | $result = prop2Str(0x0037001E); |
||
| 71 | $this->assertIsString($result); |
||
| 72 | |||
| 73 | // Test with string (should return as-is) |
||
| 74 | $this->assertEquals('test', prop2Str('test')); |
||
| 75 | } |
||
| 76 | |||
| 77 | public function testRelOpToString(): void { |
||
| 78 | $this->assertEquals('RELOP_LT', relOpToString(RELOP_LT)); |
||
| 79 | $this->assertEquals('RELOP_LE', relOpToString(RELOP_LE)); |
||
| 80 | $this->assertEquals('RELOP_GT', relOpToString(RELOP_GT)); |
||
| 81 | $this->assertEquals('RELOP_GE', relOpToString(RELOP_GE)); |
||
| 82 | $this->assertEquals('RELOP_EQ', relOpToString(RELOP_EQ)); |
||
| 83 | $this->assertEquals('RELOP_NE', relOpToString(RELOP_NE)); |
||
| 84 | $this->assertEquals('RELOP_RE', relOpToString(RELOP_RE)); |
||
| 85 | |||
| 86 | // Test with unknown value |
||
| 87 | $this->assertEquals('', relOpToString(999)); |
||
| 88 | } |
||
| 89 | |||
| 90 | public function testSecondsPerDayConstant(): void { |
||
| 91 | $this->assertEquals(86400, SECONDS_PER_DAY); |
||
| 92 | } |
||
| 93 | } |
||
| 94 |
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