renaming of read and write methods for database access

readFromBB->readFromDatabase
writeDBEntry->writeToDatabase

Change-Id: I426be5dc479ad789d0e85b149a989a581945c9be
This commit is contained in:
physikerwelt 2013-04-24 06:01:53 +00:00
parent 10662ea6e3
commit 08b93eebd6
5 changed files with 14 additions and 14 deletions

View File

@ -118,7 +118,7 @@ abstract class MathRenderer {
* *
* @return boolean true if read successfully, false otherwise * @return boolean true if read successfully, false otherwise
*/ */
public function readFromDB() { public function readFromDatabase() {
$dbr = wfGetDB( DB_SLAVE ); $dbr = wfGetDB( DB_SLAVE );
$rpage = $dbr->selectRow( $rpage = $dbr->selectRow(
'math', 'math',
@ -150,7 +150,7 @@ abstract class MathRenderer {
/** /**
* Writes rendering entry to database * Writes rendering entry to database
*/ */
public function writeDBEntry() { public function writeToDatabase() {
# Now save it back to the DB: # Now save it back to the DB:
if ( !wfReadOnly() ) { if ( !wfReadOnly() ) {
$dbw = wfGetDB( DB_MASTER ); $dbw = wfGetDB( DB_MASTER );

View File

@ -279,7 +279,7 @@ class MathTexvc extends MathRenderer {
if ( $this->isRecall() ) { if ( $this->isRecall() ) {
return; return;
} }
$this->writeDBEntry(); $this->writeToDatabase();
// If we're replacing an older version of the image, make sure it's current. // If we're replacing an older version of the image, make sure it's current.
if ( $wgUseSquid ) { if ( $wgUseSquid ) {
$urls = array( $this->getMathImageUrl() ); $urls = array( $this->getMathImageUrl() );
@ -295,7 +295,7 @@ class MathTexvc extends MathRenderer {
*/ */
function readCache() { function readCache() {
global $wgMathCheckFiles; global $wgMathCheckFiles;
if ( $this->readFromDB() ) { if ( $this->readFromDatabase() ) {
if ( !$wgMathCheckFiles ) { if ( !$wgMathCheckFiles ) {
// Short-circuit the file existence & migration checks // Short-circuit the file existence & migration checks
return true; return true;

View File

@ -65,10 +65,10 @@ class MathDatabaseTest extends MediaWikiTestCase {
$this->setValues(); $this->setValues();
$wgDebugMath = false; $wgDebugMath = false;
$this->renderer->writeDBEntry(); $this->renderer->writeToDatabase();
$renderer2 = $this->getMockForAbstractClass( 'MathRenderer', array ( self::SOME_TEX ) ); $renderer2 = $this->getMockForAbstractClass( 'MathRenderer', array ( self::SOME_TEX ) );
$renderer2->readFromDB(); $renderer2->readFromDatabase();
// comparing the class object does now work due to null values etc. // comparing the class object does now work due to null values etc.
// $this->assertEquals($this->renderer,$renderer2); // $this->assertEquals($this->renderer,$renderer2);
$this->assertEquals( $this->renderer->getTex(), $renderer2->getTex(), "test if tex is the same" ); $this->assertEquals( $this->renderer->getTex(), $renderer2->getTex(), "test if tex is the same" );
@ -90,7 +90,7 @@ class MathDatabaseTest extends MediaWikiTestCase {
$dbu->doUpdates( array( "extensions" ) ); $dbu->doUpdates( array( "extensions" ) );
$this->expectOutputRegex( '/(.*)Creating math table(.*)/' ); $this->expectOutputRegex( '/(.*)Creating math table(.*)/' );
$this->setValues(); $this->setValues();
$this->renderer->writeDBEntry(); $this->renderer->writeToDatabase();
$res = $this->db->select( "math", "*" ); $res = $this->db->select( "math", "*" );
$row = $res->fetchRow(); $row = $res->fetchRow();
$this->assertEquals( sizeof( $row ), 2 * self::NUM_BASIC_FIELDS ); $this->assertEquals( sizeof( $row ), 2 * self::NUM_BASIC_FIELDS );

View File

@ -22,11 +22,11 @@ class MathRendererTest extends MediaWikiTestCase {
*/ */
public function testWriteCacheSkip() { public function testWriteCacheSkip() {
$renderer = $this->getMockBuilder( 'MathRenderer' ) $renderer = $this->getMockBuilder( 'MathRenderer' )
->setMethods( array( 'writeDBEntry' , 'render' ) ) ->setMethods( array( 'writeToDatabase' , 'render' ) )
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$renderer->expects( $this->never() ) $renderer->expects( $this->never() )
->method( 'writeDBEntry' ); ->method( 'writeToDatabase' );
$renderer->writeCache(); $renderer->writeCache();
} }
@ -36,11 +36,11 @@ class MathRendererTest extends MediaWikiTestCase {
*/ */
public function testWriteCache() { public function testWriteCache() {
$renderer = $this->getMockBuilder( 'MathRenderer' ) $renderer = $this->getMockBuilder( 'MathRenderer' )
->setMethods( array( 'writeDBEntry' , 'render' ) ) ->setMethods( array( 'writeToDatabase' , 'render' ) )
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$renderer->expects( $this->never() ) $renderer->expects( $this->never() )
->method( 'writeDBEntry' ); ->method( 'writeToDatabase' );
$renderer->writeCache(); $renderer->writeCache();
} }
} }

View File

@ -25,10 +25,10 @@ class MathTexvcTest extends MediaWikiTestCase {
// will backup / restore global state on test setup / teardown.) // will backup / restore global state on test setup / teardown.)
$wgMathCheckFiles = false; $wgMathCheckFiles = false;
// Create a MathTexvc mock, replacing methods 'readFromDB', // Create a MathTexvc mock, replacing methods 'readFromDatabase',
// 'callTexvc', and 'doHTMLRender' with test doubles. // 'callTexvc', and 'doHTMLRender' with test doubles.
$texvc = $this->getMockBuilder( 'MathTexvc' ) $texvc = $this->getMockBuilder( 'MathTexvc' )
->setMethods( array( 'readFromDB', 'callTexvc', 'doHTMLRender' ) ) ->setMethods( array( 'readFromDatabase', 'callTexvc', 'doHTMLRender' ) )
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -36,7 +36,7 @@ class MathTexvcTest extends MediaWikiTestCase {
// ... first check if the item exists in the database cache: // ... first check if the item exists in the database cache:
$texvc->expects( $this->once() ) $texvc->expects( $this->once() )
->method( 'readFromDB' ) ->method( 'readFromDatabase' )
->with() ->with()
->will( $this->returnValue( true ) ); ->will( $this->returnValue( true ) );