]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - t/inc/Database.t
MediaWiki 1.15.5
[autoinstallsdev/mediawiki.git] / t / inc / Database.t
1 #!/usr/bin/env php
2 <?php
3
4 define( 'MEDIAWIKI', true );
5 require 't/Test.php';
6
7 require 'includes/Defines.php';
8 require 'StartProfiler.php';
9 require 'includes/AutoLoader.php';
10 require 'LocalSettings.php';
11 require 'includes/Setup.php';
12
13 plan( 9 );
14
15 $db = new Database( $wgDBserver, $wgDBuser, $wgDBpassword );
16
17 cmp_ok( $db->addQuotes( NULL ), '==',
18         'NULL', 'Add quotes to NULL' );
19
20 cmp_ok( $db->addQuotes( 1234 ), '==',
21         "'1234'", 'Add quotes to int' );
22
23 cmp_ok( $db->addQuotes( 1234.5678 ), '==',
24         "'1234.5678'", 'Add quotes to float' );
25
26 cmp_ok( $db->addQuotes( 'string' ), '==',
27         "'string'", 'Add quotes to string' );
28         
29 cmp_ok( $db->addQuotes( "string's cause trouble" ), '==',
30         "'string\'s cause trouble'", 'Add quotes to quoted string' );
31
32 $sql = $db->fillPrepared(
33         'SELECT * FROM interwiki', array() );
34 cmp_ok( $sql, '==',
35         'SELECT * FROM interwiki', 'FillPrepared empty' );
36
37 $sql = $db->fillPrepared(
38         'SELECT * FROM cur WHERE cur_namespace=? AND cur_title=?',
39         array( 4, "Snicker's_paradox" ) );
40 cmp_ok( $sql, '==',
41         "SELECT * FROM cur WHERE cur_namespace='4' AND cur_title='Snicker\'s_paradox'", 'FillPrepared question' );
42
43 $sql = $db->fillPrepared(
44         'SELECT user_id FROM ! WHERE user_name=?',
45         array( '"user"', "Slash's Dot" ) );
46 cmp_ok( $sql, '==',
47         "SELECT user_id FROM \"user\" WHERE user_name='Slash\'s Dot'", 'FillPrepared quoted' );
48
49 $sql = $db->fillPrepared(
50         "SELECT * FROM cur WHERE cur_title='This_\\&_that,_WTF\\?\\!'",
51         array( '"user"', "Slash's Dot" ) );
52 cmp_ok( $sql, '==',
53         "SELECT * FROM cur WHERE cur_title='This_&_that,_WTF?!'", 'FillPrepared raw' );