2010-12-14 16:26:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
2010-12-28 18:17:16 +00:00
|
|
|
class ParserOptionsTest extends MediaWikiTestCase {
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
private $popts;
|
|
|
|
|
private $pcache;
|
|
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
protected function setUp() {
|
|
|
|
|
global $wgLanguageCode, $wgUser;
|
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
$langObj = Language::factory( $wgLanguageCode );
|
|
|
|
|
|
|
|
|
|
$this->setMwGlobals( array(
|
|
|
|
|
'wgContLang' => $langObj,
|
|
|
|
|
'wgUseDynamicDates' => true,
|
|
|
|
|
) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
$this->popts = ParserOptions::newFromUserAndLang( $wgUser, $langObj );
|
|
|
|
|
$this->pcache = ParserCache::singleton();
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ParserOptions::optionsHash was not giving consistent results when $wgUseDynamicDates was set
|
|
|
|
|
* @group Database
|
|
|
|
|
*/
|
|
|
|
|
function testGetParserCacheKeyWithDynamicDates() {
|
|
|
|
|
$title = Title::newFromText( "Some test article" );
|
2012-02-05 16:45:41 +00:00
|
|
|
$page = WikiPage::factory( $title );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2012-02-05 16:45:41 +00:00
|
|
|
$pcacheKeyBefore = $this->pcache->getKey( $page, $this->popts );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertNotNull( $this->popts->getDateFormat() );
|
2012-10-08 10:56:20 +00:00
|
|
|
|
2012-02-05 16:45:41 +00:00
|
|
|
$pcacheKeyAfter = $this->pcache->getKey( $page, $this->popts );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( $pcacheKeyBefore, $pcacheKeyAfter );
|
|
|
|
|
}
|
|
|
|
|
}
|