Localisation updates German
[mediawiki.git] / tests / DatabaseTest.php
blobdb46ad60f5816787a405f44074460b497b5013fb
1 <?php
3 class DatabaseTest extends PHPUnit_Framework_TestCase {
4 var $db;
6 function setUp() {
7 $this->db = wfGetDB( DB_SLAVE );
10 function testAddQuotesNull() {
11 $this->assertEquals(
12 'NULL',
13 $this->db->addQuotes( NULL ) );
16 function testAddQuotesInt() {
17 # returning just "1234" should be ok too, though...
18 # maybe
19 $this->assertEquals(
20 "'1234'",
21 $this->db->addQuotes( 1234 ) );
24 function testAddQuotesFloat() {
25 # returning just "1234.5678" would be ok too, though
26 $this->assertEquals(
27 "'1234.5678'",
28 $this->db->addQuotes( 1234.5678 ) );
31 function testAddQuotesString() {
32 $this->assertEquals(
33 "'string'",
34 $this->db->addQuotes( 'string' ) );
37 function testAddQuotesStringQuote() {
38 $this->assertEquals(
39 "'string\'s cause trouble'",
40 $this->db->addQuotes( "string's cause trouble" ) );
43 function testFillPreparedEmpty() {
44 $sql = $this->db->fillPrepared(
45 'SELECT * FROM interwiki', array() );
46 $this->assertEquals(
47 "SELECT * FROM interwiki",
48 $sql);
51 function testFillPreparedQuestion() {
52 $sql = $this->db->fillPrepared(
53 'SELECT * FROM cur WHERE cur_namespace=? AND cur_title=?',
54 array( 4, "Snicker's_paradox" ) );
55 $this->assertEquals(
56 "SELECT * FROM cur WHERE cur_namespace='4' AND cur_title='Snicker\'s_paradox'",
57 $sql);
60 function testFillPreparedBang() {
61 $sql = $this->db->fillPrepared(
62 'SELECT user_id FROM ! WHERE user_name=?',
63 array( '"user"', "Slash's Dot" ) );
64 $this->assertEquals(
65 "SELECT user_id FROM \"user\" WHERE user_name='Slash\'s Dot'",
66 $sql);
69 function testFillPreparedRaw() {
70 $sql = $this->db->fillPrepared(
71 "SELECT * FROM cur WHERE cur_title='This_\\&_that,_WTF\\?\\!'",
72 array( '"user"', "Slash's Dot" ) );
73 $this->assertEquals(
74 "SELECT * FROM cur WHERE cur_title='This_&_that,_WTF?!'",
75 $sql);