ResourceLoaderULSModule::getModifiedTime updates continuously
Fix is simple: cache the hash of content per language Added PHPUnit test for the same Bug: 56856 Change-Id: I590b27af220d6e790c70728062d1a04c098b3d11
This commit is contained in:
committed by
Santhosh Thottingal
parent
6cd178359e
commit
bd52ae0538
49
tests/phpunit/ResourceLoaderULSTest.php
Normal file
49
tests/phpunit/ResourceLoaderULSTest.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Unit tests for ResourceLoaderULSModule class.
|
||||
*
|
||||
* @file
|
||||
* @ingroup Extensions
|
||||
*
|
||||
* @author Santhosh Thottingal
|
||||
*/
|
||||
|
||||
/**
|
||||
* @covers ResourceLoaderULSModule
|
||||
*/
|
||||
class ResourceLoaderULSModuleMemcachedTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* Test whether the modified time of the RL module varies
|
||||
* correctly with language code.
|
||||
* @covers ResourceLoaderSchemaModule::getModifiedTime
|
||||
*/
|
||||
function testModifiedTime() {
|
||||
$request = new WebRequest();
|
||||
$module = new ResourceLoaderULSModule();
|
||||
|
||||
$request->setVal( 'lang', 'he' );
|
||||
$context = new ResourceLoaderContext(
|
||||
new ResourceLoader(), $request );
|
||||
$mtimeHebrew = $module->getModifiedTime( $context );
|
||||
// sleep for 1 second
|
||||
sleep( 1 );
|
||||
$request->setVal( 'lang', 'hi' );
|
||||
$context = new ResourceLoaderContext( new ResourceLoader(), $request );
|
||||
$mtimeHindi = $module->getModifiedTime( $context );
|
||||
$this->assertGreaterThan( $mtimeHebrew, $mtimeHindi, "Hindi has recent timestamp than Hebrew" );
|
||||
|
||||
// sleep for 1 second
|
||||
sleep( 1 );
|
||||
$request->setVal( 'lang', 'he' );
|
||||
$context = new ResourceLoaderContext( new ResourceLoader(), $request );
|
||||
$mtimeHebrewNew = $module->getModifiedTime( $context );
|
||||
$this->assertEquals( $mtimeHebrewNew, $mtimeHebrew, "Hebrew timestamp remained same" );
|
||||
|
||||
// sleep for 1 second
|
||||
sleep( 1 );
|
||||
$request->setVal( 'lang', 'hi' );
|
||||
$context = new ResourceLoaderContext( new ResourceLoader(), $request );
|
||||
$mtimeHindiNew = $module->getModifiedTime( $context );
|
||||
$this->assertEquals( $mtimeHindi, $mtimeHindiNew, "Hindi timestamp remained same" );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user