mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-25 16:58:35 +00:00
db07787390
https://www.mediawiki.org/wiki/Extension:Scribunto says that master requires 1.25+, so let's remove checks for stuff that was added before that. * PPFrame::getTTL() was in 1.24. * PPFrame::setTTL() was in 1.24. * PPFrame::isVolatile() was in 1.24. * Parser::fetchCurrentRevisionOfTitle() was in 1.24. * ObjectCache::getLocalServerInstance() was added in 1.27, so restore the call to ObjectCache::newAccelerator() as BC. This also removes BC with the php-luasandbox extension older than 1.6, which was released before MediaWiki 1.22. Bug: T148012 Change-Id: I36e37f3b65d0f167e1d28b00e0842d9721feee31
71 lines
2.2 KiB
PHP
71 lines
2.2 KiB
PHP
<?php
|
|
|
|
// @codingStandardsIgnoreLine Squiz.Classes.ValidClassName.NotCamelCaps
|
|
class Scribunto_LuaLanguageLibraryTests extends Scribunto_LuaEngineTestBase {
|
|
protected static $moduleName = 'LanguageLibraryTests';
|
|
|
|
public function __construct(
|
|
$name = null, array $data = array(), $dataName = '', $engineName = null
|
|
) {
|
|
parent::__construct( $name, $data, $dataName, $engineName );
|
|
|
|
// Skip certain tests if something isn't providing translated language names
|
|
// (bug 67343)
|
|
if ( Language::fetchLanguageName( 'en', 'fr' ) === 'English' ) {
|
|
$msg = 'Language name translations are unavailable; ' .
|
|
'install Extension:CLDR or something similar';
|
|
$this->skipTests += array(
|
|
'fetchLanguageName (en,ru)' => $msg,
|
|
'fetchLanguageName (ru,en)' => $msg,
|
|
'fetchLanguageNames (de)' => $msg,
|
|
'fetchLanguageNames ([[bogus]])' => $msg,
|
|
);
|
|
}
|
|
}
|
|
|
|
protected function getTestModules() {
|
|
return parent::getTestModules() + array(
|
|
'LanguageLibraryTests' => __DIR__ . '/LanguageLibraryTests.lua',
|
|
);
|
|
}
|
|
|
|
public function testFormatDateTTLs() {
|
|
global $wgContLang;
|
|
|
|
$engine = $this->getEngine();
|
|
$pp = $engine->getParser()->getPreprocessor();
|
|
|
|
$ttl = null;
|
|
$wgContLang->sprintfDate( 's', '20130101000000', null, $ttl );
|
|
if ( $ttl === null ) {
|
|
$this->markTestSkipped( "Language::sprintfDate does not set a TTL" );
|
|
}
|
|
|
|
// sprintfDate has its own unit tests for making sure its output is right,
|
|
// so all we need to test here is we get TTLs when we're supposed to
|
|
$this->extraModules['Module:FormatDate'] = '
|
|
local p = {}
|
|
function p.formatCurrentDate()
|
|
return mw.getContentLanguage():formatDate( "s" )
|
|
end
|
|
function p.formatSpecificDate()
|
|
return mw.getContentLanguage():formatDate( "s", "20130101000000" )
|
|
end
|
|
return p
|
|
';
|
|
|
|
$title = Title::makeTitle( NS_MODULE, 'FormatDate' );
|
|
$module = $engine->fetchModuleFromParser( $title );
|
|
|
|
$frame = $pp->newFrame();
|
|
$module->invoke( 'formatCurrentDate', $frame );
|
|
$this->assertEquals( 1, $frame->getTTL(),
|
|
'TTL must be equal to 1 second when lang:formatDate( \'s\' ) is called' );
|
|
|
|
$frame = $pp->newFrame();
|
|
$module->invoke( 'formatSpecificDate', $frame );
|
|
$this->assertNull( $frame->getTTL(),
|
|
'TTL must not be set when lang:formatDate is called with a specific date' );
|
|
}
|
|
}
|