blob: 54c9f5d31a6ab44092835ca2a9f1628a3423d372 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
/**
* Unit tests.
*
* @author Niklas Laxström
* @file
* @license GPL-2.0-or-later
*/
class MessageGroupStatsTest extends PHPUnit\Framework\TestCase {
public function testGetDatabaseIdForGroupId() {
$shortId = 'abab';
$longId = str_repeat( 'ab', 100 );
$this->assertLessThanOrEqual(
100,
strlen( MessageGroupStats::getDatabaseIdForGroupId( $shortId ) ),
'Short id is <= 100 bytes long'
);
$this->assertLessThanOrEqual(
100,
strlen( MessageGroupStats::getDatabaseIdForGroupId( $longId ) ),
'Long id is <= 100 bytes long'
);
$longId1 = str_repeat( 'ab', 100 ) . '1';
$longId2 = str_repeat( 'ab', 100 ) . '2';
$this->assertNotEquals(
MessageGroupStats::getDatabaseIdForGroupId( $longId1 ),
MessageGroupStats::getDatabaseIdForGroupId( $longId2 ),
'Two long ids with the same prefix do not collide'
);
}
}
|