Merge "Gallery: Use intrinsic width for gallery to center caption"
[lhc/web/wiklou.git] / tests / phpunit / includes / search / SearchIndexFieldTest.php
1 <?php
2
3 /**
4 * @group Search
5 * @covers SearchIndexFieldDefinition
6 */
7 class SearchIndexFieldTest extends MediaWikiTestCase {
8
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 ],
16 ];
17 }
18
19 /**
20 * @dataProvider getMergeCases
21 */
22 public function testMerge( $t1, $n1, $t2, $n2, $result ) {
23 $field1 = $this->getMockBuilder( 'SearchIndexFieldDefinition' )
24 ->setMethods( [ 'getMapping' ] )
25 ->setConstructorArgs( [ $n1, $t1 ] )->getMock();
26 $field2 = $this->getMockBuilder( 'SearchIndexFieldDefinition' )
27 ->setMethods( [ 'getMapping' ] )
28 ->setConstructorArgs( [ $n2, $t2 ] )->getMock();
29
30 if ( $result ) {
31 $this->assertNotFalse( $field1->merge( $field2 ) );
32 } else {
33 $this->assertFalse( $field1->merge( $field2 ) );
34 }
35
36 $field1->setFlag( 0xFF );
37 $this->assertFalse( $field1->merge( $field2 ) );
38 }
39 }