20 $config = new \HashConfig( [
21 'ParserCacheExpireTime' => \IExpiringStore::TTL_INDEFINITE,
24 $context = $this->createMock( \IContextSource::class );
26 ->willReturn( $config );
28 $main = $this->createMock( \ApiMain::class );
29 $main->expects( $this->once() )
30 ->method(
'getContext' )
33 $query = $this->createMock( \ApiQuery::class );
34 $query->expects( $this->once() )
36 ->willReturn( $main );
44 $title = $this->createMock( \Title::class );
45 $title->method(
'getPageLanguage' )
46 ->willReturn( $this->createMock( \Language::class ) );
48 $page = $this->createMock( \WikiPage::class );
49 $page->method(
'getTitle' )
52 $text =
'Text to cache';
55 $instance = TestingAccessWrapper::newFromObject( $this->
newInstance() );
56 $this->assertFalse( $instance->getFromCache( $page,
false ),
'is not cached yet' );
57 $instance->setCache( $page, $text );
58 $this->assertSame( $text, $instance->getFromCache( $page,
false ) );
63 $instance = TestingAccessWrapper::newFromObject( $this->
newInstance() );
65 $this->assertInternalType(
'string', $instance->getCacheMode( [] ) );
66 $this->assertNotEmpty( $instance->getExamplesMessages() );
67 $this->assertInternalType(
'string', $instance->getHelpUrls() );
69 $params = $instance->getAllowedParams();
70 $this->assertInternalType(
'array', $params );
72 $this->assertSame( $params[
'chars'][\ApiBase::PARAM_MIN], 1 );
73 $this->assertSame( $params[
'chars'][\ApiBase::PARAM_MAX], 1200 );
75 $this->assertSame( $params[
'limit'][\ApiBase::PARAM_DFLT], 20 );
76 $this->assertSame( $params[
'limit'][\ApiBase::PARAM_TYPE],
'limit' );
77 $this->assertSame( $params[
'limit'][\ApiBase::PARAM_MIN], 1 );
78 $this->assertSame( $params[
'limit'][\ApiBase::PARAM_MAX], 20 );
79 $this->assertSame( $params[
'limit'][\ApiBase::PARAM_MAX2], 20 );