SkinMinerva testGetContextSpecificModule test might use undefined title

Test scenario for getContextSpecificModules() mocks only Skin->getTitle()
behavior, but while executing isAllowedPageAction() Skin will create a
UserPageHelper with default RequestContext. As RequestContext is not mocked,
$context->getTitle() will return undefined what could lead to tests crash

Changes:
 - instead of mocking SkinMinerva::getTitle() pass test context with injected
title. Other tests will work properly as MediaWikiTestCase::tearDown() always
restes RequestContext to default

Bug: T170624
Change-Id: I872fddf8d9c52a6875bb6c69a12407a8125fba4c
This commit is contained in:
Piotr Miazga 2017-07-17 21:34:45 +02:00
parent 8653b8b4b1
commit 9d90df7b0b
1 changed files with 3 additions and 3 deletions

View File

@ -177,10 +177,10 @@ class SkinMinervaTest extends MediaWikiTestCase {
->getMock()
);
$title = Title::newFromText( 'Test' );
$skin->expects( $this->any() )
->method( 'getTitle' )
->will( $this->returnValue( $title ) );
$testContext = RequestContext::getMain();
$testContext->setTitle( $title );
$skin->setContext ( $testContext );
$skin->setSkinOptions( [
'fontChanger' => $fontchangerValue,
'backToTop' => $backToTopValue,