5 * @covers SearchIndexFieldDefinition
7 class SearchIndexFieldTest
extends MediaWikiTestCase
{
9 public function getMergeCases() {
11 [ 0, 'test', 0, 'test', true ],
12 [ SearchIndexField
::INDEX_TYPE_NESTED
, 'test',
13 SearchIndexField
::INDEX_TYPE_NESTED
, 'test', false ],
14 [ 0, 'test', 0, 'test2', true ],
15 [ 0, 'test', 1, 'test', false ],
20 * @dataProvider getMergeCases
27 public function testMerge( $t1, $n1, $t2, $n2, $result ) {
29 $this->getMockBuilder( SearchIndexFieldDefinition
::class )
30 ->setMethods( [ 'getMapping' ] )
31 ->setConstructorArgs( [ $n1, $t1 ] )
34 $this->getMockBuilder( SearchIndexFieldDefinition
::class )
35 ->setMethods( [ 'getMapping' ] )
36 ->setConstructorArgs( [ $n2, $t2 ] )
40 $this->assertNotFalse( $field1->merge( $field2 ) );
42 $this->assertFalse( $field1->merge( $field2 ) );
45 $field1->setFlag( 0xFF );
46 $this->assertFalse( $field1->merge( $field2 ) );
48 $field1->setMergeCallback(
53 $this->assertEquals( "test", $field1->merge( $field2 ) );