r90364 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90363‎ | r90364 | r90365 >
Date:20:37, 18 June 2011
Author:maxsem
Status:ok
Tags:
Comment:
Follow-up r90356 & r90363: test deleteJoin() on SQLite
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php
@@ -38,6 +38,19 @@
3939 return preg_replace( '/\s+/', ' ', $this->db->replaceVars( $sql ) );
4040 }
4141
 42+ private function assertResultIs( $expected, $res ) {
 43+ $this->assertNotNull( $res );
 44+ $i = 0;
 45+ foreach( $res as $row ) {
 46+ foreach( $expected[$i] as $key => $value ) {
 47+ $this->assertTrue( isset( $row->$key ) );
 48+ $this->assertEquals( $value, $row->$key );
 49+ }
 50+ $i++;
 51+ }
 52+ $this->assertEquals( count( $expected ), $i, 'Unexpected number of rows' );
 53+ }
 54+
4255 public function testReplaceVars() {
4356 $this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't break anything accidentally" );
4457
@@ -127,6 +140,33 @@
128141 );
129142 }
130143
 144+ public function testDeleteJoin() {
 145+ $db = new DatabaseSqliteStandalone( ':memory:' );
 146+ $db->query( 'CREATE TABLE a (a_1)', __METHOD__ );
 147+ $db->query( 'CREATE TABLE b (b_1, b_2)', __METHOD__ );
 148+ $db->insert( 'a', array(
 149+ array( 'a_1' => 1 ),
 150+ array( 'a_1' => 2 ),
 151+ array( 'a_1' => 3 ),
 152+ ),
 153+ __METHOD__
 154+ );
 155+ $db->insert( 'b', array(
 156+ array( 'b_1' => 2, 'b_2' => 'a' ),
 157+ array( 'b_1' => 3, 'b_2' => 'b' ),
 158+ ),
 159+ __METHOD__
 160+ );
 161+ $db->deleteJoin( 'a', 'b', 'a_1', 'b_1', array( 'b_2' => 'a' ), __METHOD__ );
 162+ $res = $db->query( "SELECT * FROM a", __METHOD__ );
 163+ $this->assertResultIs( array(
 164+ array( 'a_1' => 1 ),
 165+ array( 'a_1' => 3 ),
 166+ ),
 167+ $res
 168+ );
 169+ }
 170+
131171 public function testEntireSchema() {
132172 global $IP;
133173

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90356(bug 29476) DatabaseBase::deleteJoin fails for Sqlite...mgrabovsky18:58, 18 June 2011
r90363All the databases but MySQL were overriding DatabaseBase::deleteJoin() with t...platonides20:26, 18 June 2011

Status & tagging log