summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/tests/phpunit/TranslationStashStorageTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Translate/tests/phpunit/TranslationStashStorageTest.php')
-rw-r--r--www/wiki/extensions/Translate/tests/phpunit/TranslationStashStorageTest.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/www/wiki/extensions/Translate/tests/phpunit/TranslationStashStorageTest.php b/www/wiki/extensions/Translate/tests/phpunit/TranslationStashStorageTest.php
new file mode 100644
index 00000000..0908f3f9
--- /dev/null
+++ b/www/wiki/extensions/Translate/tests/phpunit/TranslationStashStorageTest.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * @file
+ * @author Niklas Laxström
+ * @license GPL-2.0-or-later
+ */
+
+/**
+ * @group Database
+ */
+class TranslationStashStorageTest extends MediaWikiTestCase {
+
+ public function testAdd() {
+ $storage = new TranslationStashStorage( wfGetDB( DB_MASTER ) );
+
+ $translation1 = new StashedTranslation(
+ User::newFromId( 1 ),
+ Title::makeTitle( NS_MAIN, __METHOD__ ),
+ 'test value',
+ [ 'kissa', 'kala' ]
+ );
+
+ $translation2 = new StashedTranslation(
+ User::newFromId( 2 ),
+ Title::makeTitle( NS_MAIN, __METHOD__ ),
+ 'test value 2',
+ [ 'kissa', 'kala' ]
+ );
+
+ $storage->addTranslation( $translation1 );
+ $storage->addTranslation( $translation2 );
+
+ $ret = $storage->getTranslations( User::newFromId( 1 ) );
+ $this->assertCount( 1, $ret, 'One stashed translation for this user' );
+
+ // AssertSame required same reference, assert equals only same content
+ $this->assertEquals( $translation1, $ret[0], 'Data roundtrips' );
+ }
+}