wiki.techinc.nl/tests/phpunit/includes/search/SearchIndexFieldTest.php
Erik Bernhardson e4fb4f978b Don't use $this as a function argument
PHP 7.1 adds the limitation that $this cannot be used as a function
parameter. Ensure forward compatability by renaming the parameters.

Bug: T160144
Change-Id: I33d2ab1ffeeeb32e3a467cc146ee8feef0255258
2017-03-13 11:12:50 -07:00

57 lines
1.3 KiB
PHP

<?php
/**
* @group Search
* @covers SearchIndexFieldDefinition
*/
class SearchIndexFieldTest extends MediaWikiTestCase {
public function getMergeCases() {
return [
[ 0, 'test', 0, 'test', true ],
[ SearchIndexField::INDEX_TYPE_NESTED, 'test',
SearchIndexField::INDEX_TYPE_NESTED, 'test', false ],
[ 0, 'test', 0, 'test2', true ],
[ 0, 'test', 1, 'test', false ],
];
}
/**
* @dataProvider getMergeCases
* @param $t1
* @param $n1
* @param $t2
* @param $n2
* @param $result
*/
public function testMerge( $t1, $n1, $t2, $n2, $result ) {
$field1 =
$this->getMockBuilder( SearchIndexFieldDefinition::class )
->setMethods( [ 'getMapping' ] )
->setConstructorArgs( [ $n1, $t1 ] )
->getMock();
$field2 =
$this->getMockBuilder( SearchIndexFieldDefinition::class )
->setMethods( [ 'getMapping' ] )
->setConstructorArgs( [ $n2, $t2 ] )
->getMock();
if ( $result ) {
$this->assertNotFalse( $field1->merge( $field2 ) );
} else {
$this->assertFalse( $field1->merge( $field2 ) );
}
$field1->setFlag( 0xFF );
$this->assertFalse( $field1->merge( $field2 ) );
$field1->setMergeCallback(
function ( $a, $b ) {
return "test";
}
);
$this->assertEquals( "test", $field1->merge( $field2 ) );
}
}