rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / search / SearchIndexFieldTest.php
blob8b4119e0d353154a01afa58d20adafa82af0cedc
1 <?php
3 /**
4 * @group Search
5 * @covers SearchIndexFieldDefinition
6 */
7 class SearchIndexFieldTest extends MediaWikiTestCase {
9 public function getMergeCases() {
10 return [
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 ],
19 /**
20 * @dataProvider getMergeCases
21 * @param int $t1
22 * @param string $n1
23 * @param int $t2
24 * @param string $n2
25 * @param bool $result
27 public function testMerge( $t1, $n1, $t2, $n2, $result ) {
28 $field1 =
29 $this->getMockBuilder( SearchIndexFieldDefinition::class )
30 ->setMethods( [ 'getMapping' ] )
31 ->setConstructorArgs( [ $n1, $t1 ] )
32 ->getMock();
33 $field2 =
34 $this->getMockBuilder( SearchIndexFieldDefinition::class )
35 ->setMethods( [ 'getMapping' ] )
36 ->setConstructorArgs( [ $n2, $t2 ] )
37 ->getMock();
39 if ( $result ) {
40 $this->assertNotFalse( $field1->merge( $field2 ) );
41 } else {
42 $this->assertFalse( $field1->merge( $field2 ) );
45 $field1->setFlag( 0xFF );
46 $this->assertFalse( $field1->merge( $field2 ) );
48 $field1->setMergeCallback(
49 function ( $a, $b ) {
50 return "test";
53 $this->assertEquals( "test", $field1->merge( $field2 ) );