diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2012-09-02 15:19:34 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2012-09-02 15:19:34 +0200 |
commit | 9498a3d2852ace0f4ee23598f542dbce3fd2ec28 (patch) | |
tree | 5aeced25a9fc09f93682788259f5c7d6d248634d /tests | |
parent | 588cc40aeec0165400421ef9612e81b6d2c7b936 (diff) |
Update to MediaWiki 1.19.2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/parser/parserTests.txt | 15 | ||||
-rw-r--r-- | tests/phpunit/includes/db/DatabaseTest.php | 92 |
2 files changed, 107 insertions, 0 deletions
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index d304b19c..11a55163 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -1733,6 +1733,21 @@ Link with double quotes in title part (literal) and alternate part (interpreted) !! end !! test +Broken image links with HTML captions (bug 39700) +!! input +[[File:Nonexistent|<script></script>]] +[[File:Nonexistent|100px|<script></script>]] +[[File:Nonexistent|<]] +[[File:Nonexistent|a<i>b</i>c]] +!! result +<p><a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><script></script></a> +<a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><script></script></a> +<a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><</a> +<a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a> +</p> +!! end + +!! test Plain link to URL !! input [[http://www.example.com]] diff --git a/tests/phpunit/includes/db/DatabaseTest.php b/tests/phpunit/includes/db/DatabaseTest.php index 672e6645..379ffb17 100644 --- a/tests/phpunit/includes/db/DatabaseTest.php +++ b/tests/phpunit/includes/db/DatabaseTest.php @@ -57,6 +57,98 @@ class DatabaseTest extends MediaWikiTestCase { $this->db->addQuotes( "string's cause trouble" ) ); } + private function getSharedTableName( $table, $database, $prefix, $format = 'quoted' ) { + global $wgSharedDB, $wgSharedTables, $wgSharedPrefix; + + $oldName = $wgSharedDB; + $oldTables = $wgSharedTables; + $oldPrefix = $wgSharedPrefix; + + $wgSharedDB = $database; + $wgSharedTables = array( $table ); + $wgSharedPrefix = $prefix; + + $ret = $this->db->tableName( $table, $format ); + + $wgSharedDB = $oldName; + $wgSharedTables = $oldTables; + $wgSharedPrefix = $oldPrefix; + + return $ret; + } + + private function prefixAndQuote( $table, $database = null, $prefix = null, $format = 'quoted' ) { + if ( $this->db->getType() === 'sqlite' || $format !== 'quoted' ) { + $quote = ''; + } elseif ( $this->db->getType() === 'mysql' ) { + $quote = '`'; + } else { + $quote = '"'; + } + + if ( $database !== null ) { + $database = $quote . $database . $quote . '.'; + } + + if ( $prefix === null ) { + $prefix = $this->dbPrefix(); + } + + return $database . $quote . $prefix . $table . $quote; + } + + function testTableNameLocal() { + $this->assertEquals( + $this->prefixAndQuote( 'tablename' ), + $this->db->tableName( 'tablename' ) + ); + } + + function testTableNameRawLocal() { + $this->assertEquals( + $this->prefixAndQuote( 'tablename', null, null, 'raw' ), + $this->db->tableName( 'tablename', 'raw' ) + ); + } + + function testTableNameShared() { + $this->assertEquals( + $this->prefixAndQuote( 'tablename', 'sharedatabase', 'sh_' ), + $this->getSharedTableName( 'tablename', 'sharedatabase', 'sh_' ) + ); + + $this->assertEquals( + $this->prefixAndQuote( 'tablename', 'sharedatabase', null ), + $this->getSharedTableName( 'tablename', 'sharedatabase', null ) + ); + } + + function testTableNameRawShared() { + $this->assertEquals( + $this->prefixAndQuote( 'tablename', 'sharedatabase', 'sh_', 'raw' ), + $this->getSharedTableName( 'tablename', 'sharedatabase', 'sh_', 'raw' ) + ); + + $this->assertEquals( + $this->prefixAndQuote( 'tablename', 'sharedatabase', null, 'raw' ), + $this->getSharedTableName( 'tablename', 'sharedatabase', null, 'raw' ) + ); + } + + function testTableNameForeign() { + $this->assertEquals( + $this->prefixAndQuote( 'tablename', 'databasename', '' ), + $this->db->tableName( 'databasename.tablename' ) + ); + } + + function testTableNameRawForeign() { + $this->assertEquals( + $this->prefixAndQuote( 'tablename', 'databasename', '', 'raw' ), + $this->db->tableName( 'databasename.tablename', 'raw' ) + ); + } + function testFillPreparedEmpty() { $sql = $this->db->fillPrepared( 'SELECT * FROM interwiki', array() ); |