summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/tests/phpunit/utils/MessageGroupStatsTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Translate/tests/phpunit/utils/MessageGroupStatsTest.php')
-rw-r--r--www/wiki/extensions/Translate/tests/phpunit/utils/MessageGroupStatsTest.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/www/wiki/extensions/Translate/tests/phpunit/utils/MessageGroupStatsTest.php b/www/wiki/extensions/Translate/tests/phpunit/utils/MessageGroupStatsTest.php
new file mode 100644
index 00000000..801ca0da
--- /dev/null
+++ b/www/wiki/extensions/Translate/tests/phpunit/utils/MessageGroupStatsTest.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @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'
+ );
+ }
+}