MediaWiki REL1_32
SearchResultTest.php
Go to the documentation of this file.
1<?php
2
3class SearchResultTest extends MediawikiTestCase {
8 public function testExtensionData() {
9 $result = SearchResult::newFromTitle( Title::newMainPage() );
10 $this->assertEquals( [], $result->getExtensionData(), 'starts empty' );
11
12 $data = [ 'hello' => 'world' ];
13 $result->setExtensionData( function () use ( &$data ) {
14 return $data;
15 } );
16 $this->assertEquals( $data, $result->getExtensionData(), 'can set extension data' );
17 $data['this'] = 'that';
18 $this->assertEquals( $data, $result->getExtensionData(), 'refetches from callback' );
19 }
20
25 public function testExtensionDataArrayBC() {
26 $result = SearchResult::newFromTitle( Title::newMainPage() );
27 $data = [ 'hello' => 'world' ];
28 $this->hideDeprecated( 'SearchResult::setExtensionData with array argument' );
29 $this->assertEquals( [], $result->getExtensionData(), 'starts empty' );
30 $result->setExtensionData( $data );
31 $this->assertEquals( $data, $result->getExtensionData(), 'can set extension data' );
32 $data['this'] = 'that';
33 $this->assertNotEquals( $data, $result->getExtensionData(), 'shouldnt hold any reference' );
34
35 $result->setExtensionData( $data );
36 $this->assertEquals( $data, $result->getExtensionData(), 'can replace extension data' );
37 }
38}
testExtensionData()
SearchResult::getExtensionData SearchResult::setExtensionData.
testExtensionDataArrayBC()
SearchResult::getExtensionData SearchResult::setExtensionData.