$this->startAtomic( $fname, self::ATOMIC_CANCELABLE );
foreach ( $a as $v ) {
parent::insert( $table, $v, "$fname/multi-row", $options );
+ $affectedRowCount += $this->affectedRows();
}
$this->endAtomic( $fname );
} catch ( Exception $e ) {
$this->assertTrue( $db->close(), "closing database" );
}
+ /**
+ * @covers DatabaseSqlite::insert
+ */
+ public function testInsertAffectedRows() {
+ $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
+ $db->query( 'CREATE TABLE testInsertAffectedRows ( foo )', __METHOD__ );
+
+ $insertion = $db->insert(
+ 'testInsertAffectedRows',
+ [
+ [ 'foo' => 10 ],
+ [ 'foo' => 12 ],
+ [ 'foo' => 1555 ],
+ ],
+ __METHOD__
+ );
+ $this->assertTrue( $insertion, "Insertion worked" );
+
+ $this->assertSame( 3, $db->affectedRows() );
+ $this->assertTrue( $db->close(), "closing database" );
+ }
+
private function prepareTestDB( $version ) {
static $maint = null;
if ( $maint === null ) {