Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / search / SearchResultTraitTest.php
blob339d01875914f0e380692e71100497f6c1c2a7a6
1 <?php
3 class SearchResultTraitTest extends MediaWikiIntegrationTestCase {
4 /**
5 * @covers \SearchResultTrait::getExtensionData
6 * @covers \SearchResultTrait::setExtensionData
7 */
8 public function testExtensionData() {
9 $result = new class() {
10 use SearchResultTrait;
12 $this->assertEquals( [], $result->getExtensionData(), 'starts empty' );
14 $data = [ 'hello' => 'world' ];
15 $result->setExtensionData( static function () use ( &$data ) {
16 return $data;
17 } );
18 $this->assertEquals( $data, $result->getExtensionData(), 'can set extension data' );
19 $data['this'] = 'that';
20 $this->assertEquals( $data, $result->getExtensionData(), 'refetches from callback' );
23 /**
24 * @covers \SearchResultTrait::getExtensionData
25 * @covers \SearchResultTrait::setExtensionData
27 public function testExtensionDataArrayBC() {
28 $result = new class() {
29 use SearchResultTrait;
31 $data = [ 'hello' => 'world' ];
32 $this->hideDeprecated( 'SearchResultTrait::setExtensionData with array argument' );
33 $this->assertEquals( [], $result->getExtensionData(), 'starts empty' );
34 $result->setExtensionData( $data );
35 $this->assertEquals( $data, $result->getExtensionData(), 'can set extension data' );
36 $data['this'] = 'that';
37 $this->assertNotEquals( $data, $result->getExtensionData(), 'shouldnt hold any reference' );
39 $result->setExtensionData( $data );
40 $this->assertEquals( $data, $result->getExtensionData(), 'can replace extension data' );