summaryrefslogtreecommitdiff
blob: e7a51fa58adffa9113bb41c4126fd8dd576beac3 (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
37
38
39
<?php
/**
 * @file
 * @author Niklas Laxström
 * @license GPL-2.0-or-later
 */

/**
 * @group Database
 */
class TranslationStashStorageTest extends MediaWikiIntegrationTestCase {

	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' );
	}
}