mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-23 23:25:02 +00:00
94b035b26a
* Include generated tests for a better test coverage of the Math extension. * Compiles texvc in testsuite (if required) * Test generator now included * Replaces the old parser tests * Fixes whitspace issues Bug: 61090 Change-Id: Iff7eeb5ee72137492c3f6659e4d4d106e5715586
76 lines
2.2 KiB
PHP
76 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* Test the database access and core functionallity of MathRenderer.
|
|
*
|
|
* @group Math
|
|
*/
|
|
class MathRendererTest extends MediaWikiTestCase {
|
|
/**
|
|
* Checks the tex and hash functions
|
|
* @covers MathRenderer::getTex()
|
|
* @covers MathRenderer::__construct()
|
|
*/
|
|
public function testBasics() {
|
|
$renderer = $this->getMockForAbstractClass( 'MathRenderer'
|
|
, array ( MathDatabaseTest::SOME_TEX ) );
|
|
// check if the TeX input was corretly passed to the class
|
|
$this->assertEquals( MathDatabaseTest::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' ) )
|
|
->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' ) )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$renderer->expects( $this->never() )
|
|
->method( 'writeToDatabase' );
|
|
$renderer->writeCache();
|
|
}
|
|
|
|
/**
|
|
* Test behavior $change when the rendered hash was changed
|
|
* @covers MathRenderer::setHash()
|
|
*/
|
|
public function testChangeHash() {
|
|
$renderer = $this->getMockBuilder( 'MathRenderer' )
|
|
->setMethods( array( 'render' ) )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$this->assertEquals( $renderer->isChanged(), false
|
|
, "test if changed is initially false" );
|
|
$renderer->setHash( '0000' );
|
|
$this->assertEquals( $renderer->isChanged(), true
|
|
, "assumes that changing a hash sets changed to true" );
|
|
}
|
|
|
|
public function testSetPurge() {
|
|
$renderer = $this->getMockBuilder( 'MathRenderer' )
|
|
->setMethods( array( 'render' ) )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$renderer->setPurge();
|
|
$this->assertEquals( $renderer->isPurge(), true, "Test purge." );
|
|
|
|
}
|
|
} |