Merge "Fix MathDatabaseTest"

This commit is contained in:
jenkins-bot 2014-07-11 01:37:18 +00:00 committed by Gerrit Code Review
commit 4eebc40812
1 changed files with 14 additions and 13 deletions

View File

@ -1,10 +1,11 @@
<?php <?php
/** /**
* Test the database access and core functionality of MathRenderer. * Test the database access and core functionality of MathRenderer.
* *
* @group Math * @group Math
* @group Database //Used by needsDB * @group Database //Used by needsDB
*/ */
class MathDatabaseTest extends MediaWikiTestCase { class MathDatabaseTest extends MediaWikiTestCase {
/** /**
* @var MathRenderer * @var MathRenderer
@ -22,7 +23,7 @@ class MathDatabaseTest extends MediaWikiTestCase {
* TODO: Check if there is a way to get database access without creating * TODO: Check if there is a way to get database access without creating
* the connection to the database explicitly * the connection to the database explicitly
* function addDBData() { * function addDBData() {
* $this->tablesUsed[] = 'math'; * $this->tablesUsed[] = 'math';
* } * }
* was not sufficient. * was not sufficient.
*/ */
@ -33,8 +34,8 @@ class MathDatabaseTest extends MediaWikiTestCase {
// Create a new instance of MathSource // Create a new instance of MathSource
$this->renderer = new MathTexvc( self::SOME_TEX ); $this->renderer = new MathTexvc( self::SOME_TEX );
$this->tablesUsed[] = 'math'; $this->tablesUsed[] = 'math';
self::setupTestDB( $this->db, "mathtest" ); }
}
/** /**
* Checks the tex and hash functions * Checks the tex and hash functions
* @covers MathRenderer::getInputHash() * @covers MathRenderer::getInputHash()
@ -52,8 +53,9 @@ class MathDatabaseTest extends MediaWikiTestCase {
$this->renderer->setTex( self::SOME_TEX ); $this->renderer->setTex( self::SOME_TEX );
$this->renderer->setMathml( self::SOME_MATHML ); $this->renderer->setMathml( self::SOME_MATHML );
$this->renderer->setHtml( self::SOME_HTML ); $this->renderer->setHtml( self::SOME_HTML );
$this->renderer->setOutputHash( self::SOME_OUTPUTHASH); $this->renderer->setOutputHash( self::SOME_OUTPUTHASH );
} }
/** /**
* Checks database access. Writes an entry and reads it back. * Checks database access. Writes an entry and reads it back.
* @covers MathRenderer::writeDatabaseEntry() * @covers MathRenderer::writeDatabaseEntry()
@ -71,7 +73,6 @@ class MathDatabaseTest extends MediaWikiTestCase {
} }
/** /**
* Checks the creation of the math table without debugging enabled. * Checks the creation of the math table without debugging enabled.
* @covers MathHooks::onLoadExtensionSchemaUpdates * @covers MathHooks::onLoadExtensionSchemaUpdates
@ -86,7 +87,7 @@ class MathDatabaseTest extends MediaWikiTestCase {
$this->renderer->writeToDatabase(); $this->renderer->writeToDatabase();
$res = $this->db->select( "math", "*" ); $res = $this->db->select( "math", "*" );
$row = $res->fetchRow(); $row = $res->fetchRow();
$this->assertEquals( 10, sizeof( $row ) ); $this->assertEquals( 10, sizeof( $row ) );
} }
/* /*
@ -100,8 +101,8 @@ class MathDatabaseTest extends MediaWikiTestCase {
$this->assertTrue( $this->renderer->writeCache(), "Write new entry" ); $this->assertTrue( $this->renderer->writeCache(), "Write new entry" );
$res = $this->db->selectField( "math", "math_inputhash", $res = $this->db->selectField( "math", "math_inputhash",
array( "math_inputhash" => $inputHash ) ); array( "math_inputhash" => $inputHash ) );
$this->assertTrue( $res !== false , "Check database entry"); $this->assertTrue( $res !== false, "Check database entry" );
$this->assertTrue( $this->renderer->readFromDatabase() , "Read entry from database"); $this->assertTrue( $this->renderer->readFromDatabase(), "Read entry from database" );
$this->assertFalse( $this->renderer->isChanged() ); $this->assertFalse( $this->renderer->isChanged() );
// modify the database entry manually // modify the database entry manually
$this->db->delete( "math", array( "math_inputhash" => $inputHash ) ); $this->db->delete( "math", array( "math_inputhash" => $inputHash ) );