Looks like someone messed with RequestContext when I wasn't looking at it. WikiPage is a representation of the Title. It should not be possible for wikipage to point to a different title than the context's title. Fix this issue by unsetting WikiPage when setting title and updating title when setting wikipage. Change-Id: I40471b12d08763cb1b47b8382f96d8db94b4f319
28 lines
956 B
PHP
28 lines
956 B
PHP
<?php
|
|
|
|
class RequestContextTest extends MediaWikiTestCase {
|
|
|
|
/**
|
|
* Test the relationship between title and wikipage in RequestContext
|
|
*/
|
|
public function testWikiPageTitle() {
|
|
$context = new RequestContext();
|
|
|
|
$curTitle = Title::newFromText( "A" );
|
|
$context->setTitle( $curTitle );
|
|
$this->assertTrue( $curTitle->equals( $context->getWikiPage()->getTitle() ),
|
|
"When a title is first set WikiPage should be created on-demand for that title." );
|
|
|
|
$curTitle = Title::newFromText( "B" );
|
|
$context->setWikiPage( WikiPage::factory( $curTitle ) );
|
|
$this->assertTrue( $curTitle->equals( $context->getTitle() ),
|
|
"Title must be updated when a new WikiPage is provided." );
|
|
|
|
$curTitle = Title::newFromText( "C" );
|
|
$context->setTitle( $curTitle );
|
|
$this->assertTrue( $curTitle->equals( $context->getWikiPage()->getTitle() ),
|
|
"When a title is updated the WikiPage should be purged and recreated on-demand with the new title." );
|
|
|
|
}
|
|
|
|
}
|