Index: trunk/phase3/tests/phpunit/includes/db/DatabaseSqliteTest.php |
— | — | @@ -38,6 +38,19 @@ |
39 | 39 | return preg_replace( '/\s+/', ' ', $this->db->replaceVars( $sql ) ); |
40 | 40 | } |
41 | 41 | |
| 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 | + |
42 | 55 | public function testReplaceVars() { |
43 | 56 | $this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't break anything accidentally" ); |
44 | 57 | |
— | — | @@ -127,6 +140,33 @@ |
128 | 141 | ); |
129 | 142 | } |
130 | 143 | |
| 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 | + |
131 | 171 | public function testEntireSchema() { |
132 | 172 | global $IP; |
133 | 173 | |