mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-24 00:05:00 +00:00
Fix unit test engine↔parser assignment
In the unit tests, the engine is given a parser, but the parser is not being associated back with the engine. So in some cases, that could lead to *another*, default engine being created for certain operations. Fix that. Change-Id: I79995c2635d9e470931b84dc1854dae26772bbe3
This commit is contained in:
parent
201bf237b3
commit
981ea4c39f
|
@ -65,8 +65,6 @@ abstract class Scribunto_LuaEngineTestBase extends MediaWikiTestCase {
|
|||
$suite->setName( $className );
|
||||
|
||||
$class = new ReflectionClass( $className );
|
||||
$parser = new Parser;
|
||||
$parser->startExternalParse( Title::newMainPage(), new ParserOptions, Parser::OT_HTML, true );
|
||||
|
||||
foreach ( self::$engineConfigurations as $engineName => $opts ) {
|
||||
if ( $group !== null && $group !== $engineName ) {
|
||||
|
@ -74,10 +72,13 @@ abstract class Scribunto_LuaEngineTestBase extends MediaWikiTestCase {
|
|||
}
|
||||
|
||||
try {
|
||||
$parser = new Parser;
|
||||
$parser->startExternalParse( Title::newMainPage(), new ParserOptions, Parser::OT_HTML, true );
|
||||
$engineClass = "Scribunto_{$engineName}Engine";
|
||||
$engine = new $engineClass(
|
||||
self::$engineConfigurations[$engineName] + array( 'parser' => $parser )
|
||||
);
|
||||
$parser->scribunto_engine = $engine;
|
||||
$engine->setTitle( $parser->getTitle() );
|
||||
$engine->getInterpreter();
|
||||
} catch ( Scribunto_LuaInterpreterNotFoundError $e ) {
|
||||
|
@ -163,6 +164,7 @@ abstract class Scribunto_LuaEngineTestBase extends MediaWikiTestCase {
|
|||
$this->engine = new $class(
|
||||
self::$engineConfigurations[$this->engineName] + array( 'parser' => $parser )
|
||||
);
|
||||
$parser->scribunto_engine = $this->engine;
|
||||
$this->engine->setTitle( $parser->getTitle() );
|
||||
}
|
||||
return $this->engine;
|
||||
|
|
|
@ -16,33 +16,34 @@ class Scribunto_LuaEnvironmentComparisonTest extends MediaWikiTestCase {
|
|||
|
||||
protected $engines = array();
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
function makeEngine( $class, $opts ) {
|
||||
$parser = new Parser;
|
||||
$options = new ParserOptions;
|
||||
$options->setTemplateCallback( array( $this, 'templateCallback' ) );
|
||||
$parser->startExternalParse( Title::newMainPage(), $options, Parser::OT_HTML, true );
|
||||
$engine = new $class ( array( 'parser' => $parser ) + $opts );
|
||||
$parser->scribunto_engine = $engine;
|
||||
$engine->setTitle( $parser->getTitle() );
|
||||
$engine->getInterpreter();
|
||||
return $engine;
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
try {
|
||||
$engine = new Scribunto_LuaSandboxEngine(
|
||||
array( 'parser' => $parser ) + $this->sandboxOpts
|
||||
$this->engines['LuaSandbox'] = $this->makeEngine(
|
||||
'Scribunto_LuaSandboxEngine', $this->sandboxOpts
|
||||
);
|
||||
$engine->setTitle( $parser->getTitle() );
|
||||
$engine->getInterpreter();
|
||||
$this->engines['LuaSandbox'] = $engine;
|
||||
} catch ( Scribunto_LuaInterpreterNotFoundError $e ) {
|
||||
$this->markTestSkipped( "LuaSandbox interpreter not available" );
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$engine = new Scribunto_LuaStandaloneEngine(
|
||||
array( 'parser' => $parser ) + $this->standaloneOpts
|
||||
$this->engines['LuaStandalone'] = $this->makeEngine(
|
||||
'Scribunto_LuaStandaloneEngine', $this->standaloneOpts
|
||||
);
|
||||
$engine->setTitle( $parser->getTitle() );
|
||||
$engine->getInterpreter();
|
||||
$this->engines['LuaStandalone'] = $engine;
|
||||
} catch ( Scribunto_LuaInterpreterNotFoundError $e ) {
|
||||
$this->markTestSkipped( "LuaStandalone interpreter not available" );
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue