r60916 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60915‎ | r60916 | r60917 >
Date:02:49, 11 January 2010
Author:mah
Status:ok (Comments)
Tags:
Comment:
fix up db tests so they work withs DBs besides just MySQL. Make tests run under E_STRICT.
Modified paths:
  • /trunk/phase3/tests/DatabaseTest.php (modified) (history)
  • /trunk/phase3/tests/bootstrap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/DatabaseTest.php
@@ -8,9 +8,11 @@
99 }
1010
1111 function testAddQuotesNull() {
12 - $this->assertEquals(
13 - 'NULL',
14 - $this->db->addQuotes( null ) );
 12+ $check = "NULL";
 13+ if ( $this->db instanceOf DatabaseSqlite ) {
 14+ $check = "''";
 15+ }
 16+ $this->assertEquals( $check, $this->db->addQuotes( null ) );
1517 }
1618
1719 function testAddQuotesInt() {
@@ -35,8 +37,12 @@
3638 }
3739
3840 function testAddQuotesStringQuote() {
 41+ $check = "'string''s cause trouble'";
 42+ if ( $this->db instanceOf DatabaseMysql ) {
 43+ $check = "'string\'s cause trouble'";
 44+ }
3945 $this->assertEquals(
40 - "'string\'s cause trouble'",
 46+ $check,
4147 $this->db->addQuotes( "string's cause trouble" ) );
4248 }
4349
@@ -52,18 +58,24 @@
5359 $sql = $this->db->fillPrepared(
5460 'SELECT * FROM cur WHERE cur_namespace=? AND cur_title=?',
5561 array( 4, "Snicker's_paradox" ) );
56 - $this->assertEquals(
57 - "SELECT * FROM cur WHERE cur_namespace='4' AND cur_title='Snicker\'s_paradox'",
58 - $sql);
 62+
 63+ $check = "SELECT * FROM cur WHERE cur_namespace='4' AND cur_title='Snicker''s_paradox'";
 64+ if ( $this->db instanceOf DatabaseMysql ) {
 65+ $check = "SELECT * FROM cur WHERE cur_namespace='4' AND cur_title='Snicker\'s_paradox'";
 66+ }
 67+ $this->assertEquals( $check, $sql );
5968 }
6069
6170 function testFillPreparedBang() {
6271 $sql = $this->db->fillPrepared(
6372 'SELECT user_id FROM ! WHERE user_name=?',
6473 array( '"user"', "Slash's Dot" ) );
65 - $this->assertEquals(
66 - "SELECT user_id FROM \"user\" WHERE user_name='Slash\'s Dot'",
67 - $sql);
 74+
 75+ $check = "SELECT user_id FROM \"user\" WHERE user_name='Slash''s Dot'";
 76+ if ( $this->db instanceOf DatabaseMysql ) {
 77+ $check = "SELECT user_id FROM \"user\" WHERE user_name='Slash\'s Dot'";
 78+ }
 79+ $this->assertEquals( $check, $sql );
6880 }
6981
7082 function testFillPreparedRaw() {
Index: trunk/phase3/tests/bootstrap.php
@@ -4,9 +4,10 @@
55 $wgCommandLineMode = true;
66 define('MEDIAWIKI', 1);
77
8 -require dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR."LocalSettings.php";
 8+require dirname( dirname( __FILE__ ) ).implode( DIRECTORY_SEPARATOR, array( "", "includes", "Defines.php" ) );
99
10 -require "Defines.php";
 10+require dirname( dirname( __FILE__ ) ).DIRECTORY_SEPARATOR."LocalSettings.php";
 11+
1112 require "ProfilerStub.php";
1213 require 'GlobalFunctions.php';
1314 require 'Hooks.php';

Follow-up revisions

RevisionCommit summaryAuthorDate
r60918follow up r60916 - Use getType instead of instanceOf as suggested by Simetricalmah04:00, 11 January 2010

Comments

#Comment by Simetrical (talk | contribs)   03:01, 11 January 2010

Shouldn't you use Tim's new $db->getType() here instead of instanceof?

#Comment by MarkAHershberger (talk | contribs)   04:00, 11 January 2010

done

Status & tagging log