9 $result = SearchResult::newFromTitle( Title::newMainPage() );
10 $this->assertEquals( [], $result->getExtensionData(),
'starts empty' );
12 $data = [
'hello' =>
'world' ];
13 $result->setExtensionData(
function () use ( &$data ) {
16 $this->assertEquals( $data, $result->getExtensionData(),
'can set extension data' );
17 $data[
'this'] =
'that';
18 $this->assertEquals( $data, $result->getExtensionData(),
'refetches from callback' );
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' );
35 $result->setExtensionData( $data );
36 $this->assertEquals( $data, $result->getExtensionData(),
'can replace extension data' );