summaryrefslogtreecommitdiff
path: root/t/inc/Database.t
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2008-08-15 01:29:47 +0200
committerPierre Schmitz <pierre@archlinux.de>2008-08-15 01:29:47 +0200
commit370e83bb0dfd0c70de268c93bf07ad5ee0897192 (patch)
tree491674f4c242e4d6ba0d04eafa305174c35a3391 /t/inc/Database.t
parentf4debf0f12d0524d2b2427c55ea3f16b680fad97 (diff)
Update auf 1.13.0
Diffstat (limited to 't/inc/Database.t')
-rw-r--r--t/inc/Database.t55
1 files changed, 55 insertions, 0 deletions
diff --git a/t/inc/Database.t b/t/inc/Database.t
new file mode 100644
index 00000000..5092be9d
--- /dev/null
+++ b/t/inc/Database.t
@@ -0,0 +1,55 @@
+#!/usr/bin/env php
+<?php
+
+define( 'MEDIAWIKI', true );
+require 't/Test.php';
+
+require 'includes/Defines.php';
+require 'LocalSettings.php';
+
+plan( 13 );
+
+require_ok( 'includes/ProfilerStub.php' );
+require_ok( 'includes/GlobalFunctions.php' );
+require_ok( 'includes/Exception.php' );
+require_ok( 'includes/Database.php' );
+
+$db = new Database( $wgDBserver, $wgDBuser, $wgDBpassword );
+
+cmp_ok( $db->addQuotes( NULL ), '==',
+ 'NULL', 'Add quotes to NULL' );
+
+cmp_ok( $db->addQuotes( 1234 ), '==',
+ "'1234'", 'Add quotes to int' );
+
+cmp_ok( $db->addQuotes( 1234.5678 ), '==',
+ "'1234.5678'", 'Add quotes to float' );
+
+cmp_ok( $db->addQuotes( 'string' ), '==',
+ "'string'", 'Add quotes to string' );
+
+cmp_ok( $db->addQuotes( "string's cause trouble" ), '==',
+ "'string\'s cause trouble'", 'Add quotes to quoted string' );
+
+$sql = $db->fillPrepared(
+ 'SELECT * FROM interwiki', array() );
+cmp_ok( $sql, '==',
+ 'SELECT * FROM interwiki', 'FillPrepared empty' );
+
+$sql = $db->fillPrepared(
+ 'SELECT * FROM cur WHERE cur_namespace=? AND cur_title=?',
+ array( 4, "Snicker's_paradox" ) );
+cmp_ok( $sql, '==',
+ "SELECT * FROM cur WHERE cur_namespace='4' AND cur_title='Snicker\'s_paradox'", 'FillPrepared question' );
+
+$sql = $db->fillPrepared(
+ 'SELECT user_id FROM ! WHERE user_name=?',
+ array( '"user"', "Slash's Dot" ) );
+cmp_ok( $sql, '==',
+ "SELECT user_id FROM \"user\" WHERE user_name='Slash\'s Dot'", 'FillPrepared quoted' );
+
+$sql = $db->fillPrepared(
+ "SELECT * FROM cur WHERE cur_title='This_\\&_that,_WTF\\?\\!'",
+ array( '"user"', "Slash's Dot" ) );
+cmp_ok( $sql, '==',
+ "SELECT * FROM cur WHERE cur_title='This_&_that,_WTF?!'", 'FillPrepared raw' );