3 class SearchResultTraitTest
extends MediaWikiIntegrationTestCase
{
5 * @covers \SearchResultTrait::getExtensionData
6 * @covers \SearchResultTrait::setExtensionData
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 ) {
18 $this->assertEquals( $data, $result->getExtensionData(), 'can set extension data' );
19 $data['this'] = 'that';
20 $this->assertEquals( $data, $result->getExtensionData(), 'refetches from callback' );
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' );