mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts
synced 2024-11-14 19:30:37 +00:00
2ecb9f8f06
Change-Id: Ib1a9584cab61f71c3525b0a81d906f457dab3eb6
55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
namespace TextExtracts\Test;
|
|
|
|
use MediaWikiCoversValidator;
|
|
use TextExtracts\ApiQueryExtracts;
|
|
|
|
/**
|
|
* @covers \TextExtracts\ApiQueryExtracts
|
|
* @group TextExtracts
|
|
*/
|
|
class ApiQueryExtractsTest extends \PHPUnit\Framework\TestCase {
|
|
use MediaWikiCoversValidator;
|
|
|
|
private function newInstance() {
|
|
$context = $this->getMockBuilder( 'IContextSource' )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
|
|
$main = $this->getMockBuilder( 'ApiMain' )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$main->expects( $this->once() )
|
|
->method( 'getContext' )
|
|
->will( $this->returnValue( $context ) );
|
|
|
|
$query = $this->getMockBuilder( 'ApiQuery' )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$query->expects( $this->once() )
|
|
->method( 'getMain' )
|
|
->will( $this->returnValue( $main ) );
|
|
|
|
$config = $this->getMockBuilder( 'Config' )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
|
|
return new ApiQueryExtracts( $query, '', $config );
|
|
}
|
|
|
|
public function testGetAllowedParams() {
|
|
$instance = $this->newInstance();
|
|
$params = $instance->getAllowedParams();
|
|
$this->assertInternalType( 'array', $params );
|
|
$this->assertArrayHasKey( 'chars', $params );
|
|
$this->assertEquals( $params['chars'][\ApiBase::PARAM_MIN], 1 );
|
|
$this->assertEquals( $params['chars'][\ApiBase::PARAM_MAX], 1200 );
|
|
$this->assertArrayHasKey( 'limit', $params );
|
|
$this->assertEquals( $params['limit'][\ApiBase::PARAM_DFLT], 20 );
|
|
$this->assertEquals( $params['limit'][\ApiBase::PARAM_TYPE], 'limit' );
|
|
$this->assertEquals( $params['limit'][\ApiBase::PARAM_MIN], 1 );
|
|
$this->assertEquals( $params['limit'][\ApiBase::PARAM_MAX], 20 );
|
|
$this->assertEquals( $params['limit'][\ApiBase::PARAM_MAX2], 20 );
|
|
}
|
|
}
|