3 require_once( 'PHPUnit.php' );
4 require_once( '../includes/Defines.php' );
5 require_once( '../includes/Database.php' );
6 require_once( '../includes/GlobalFunctions.php' );
8 class DatabaseTest
extends PHPUnit_TestCase
{
11 function DatabaseTest( $name ) {
12 $this->PHPUnit_TestCase( $name );
16 $this->db
= new Database();
23 function testAddQuotesNull() {
26 $this->db
->addQuotes( NULL ) );
29 function testAddQuotesInt() {
30 # returning just "1234" should be ok too, though...
34 $this->db
->addQuotes( 1234 ) );
37 function testAddQuotesFloat() {
38 # returning just "1234.5678" would be ok too, though
41 $this->db
->addQuotes( 1234.5678 ) );
44 function testAddQuotesString() {
47 $this->db
->addQuotes( 'string' ) );
50 function testAddQuotesStringQuote() {
52 "'string\'s cause trouble'",
53 $this->db
->addQuotes( "string's cause trouble" ) );
56 function testFillPreparedEmpty() {
57 $sql = $this->db
->fillPrepared(
58 'SELECT * FROM interwiki', array() );
60 "SELECT * FROM interwiki",
64 function testFillPreparedQuestion() {
65 $sql = $this->db
->fillPrepared(
66 'SELECT * FROM cur WHERE cur_namespace=? AND cur_title=?',
67 array( 4, "Snicker's_paradox" ) );
69 "SELECT * FROM cur WHERE cur_namespace='4' AND cur_title='Snicker\'s_paradox'",
73 function testFillPreparedBang() {
74 $sql = $this->db
->fillPrepared(
75 'SELECT user_id FROM ! WHERE user_name=?',
76 array( '"user"', "Slash's Dot" ) );
78 "SELECT user_id FROM \"user\" WHERE user_name='Slash\'s Dot'",
82 function testFillPreparedRaw() {
83 $sql = $this->db
->fillPrepared(
84 "SELECT * FROM cur WHERE cur_title='This_\\&_that,_WTF\\?\\!'",
85 array( '"user"', "Slash's Dot" ) );
87 "SELECT * FROM cur WHERE cur_title='This_&_that,_WTF?!'",