mediawiki-extensions-Math/tests/MathRendererTest.php
physikerwelt (Moritz Schubotz) c7197bee19 Add separate database table for LaTeXML (step 5)
Currently the PNG and the LaTeXML rendering mode
use a common table in the database. If both rendering
modes are allowed in a wiki simultaneously this causes
problems, because the fields are continuously overwritten.

This is patch changes the logic of the rendering
engine to use the specific database.
The caching logic is now simpler to understand.
A entry is written to the database if the changed field
of the MathRenderer class is true. Is is triggered by the
setters of the database relevant fields.


Bug: 65522
Change-Id: Ief9de889b9292b21c9d1529a8b1797f38196edad
2014-05-31 10:34:21 +00:00

61 lines
1.8 KiB
PHP

<?php
/**
* Test the database access and core functionality of MathRenderer.
*
* @group Math
*/
class MathRendererTest extends MediaWikiTestCase {
const SOME_TEX = "a+b";
/**
* Checks the tex and hash functions
* @covers MathRenderer::getTex()
* @covers MathRenderer::__construct()
*/
public function testBasics() {
$renderer = $this->getMockForAbstractClass( 'MathRenderer'
, array ( self::SOME_TEX ) );
// check if the TeX input was corretly passed to the class
$this->assertEquals( self::SOME_TEX, $renderer->getTex()
, "test getTex" );
$this->assertEquals( $renderer->isChanged(), false
, "test if changed is initially false" );
}
/**
* Test behavior of writeCache() when nothing was changed
* @covers MathRenderer::writeCache()
*/
public function testWriteCacheSkip() {
$renderer = $this->getMockBuilder( 'MathRenderer' )
->setMethods( array( 'writeToDatabase' , 'render', 'getMathTableName' ) )
->disableOriginalConstructor()
->getMock();
$renderer->expects( $this->never() )
->method( 'writeToDatabase' );
$renderer->writeCache();
}
/**
* Test behavior of writeCache() when values were changed.
* @covers MathRenderer::writeCache()
*/
public function testWriteCache() {
$renderer = $this->getMockBuilder( 'MathRenderer' )
->setMethods( array( 'writeToDatabase' , 'render', 'getMathTableName' ) )
->disableOriginalConstructor()
->getMock();
$renderer->expects( $this->never() )
->method( 'writeToDatabase' );
$renderer->writeCache();
}
public function testSetPurge() {
$renderer = $this->getMockBuilder( 'MathRenderer' )
->setMethods( array( 'render', 'getMathTableName' ) )
->disableOriginalConstructor()
->getMock();
$renderer->setPurge();
$this->assertEquals( $renderer->isPurge(), true, "Test purge." );
}
}