✅ Add tests for non existent tables.
Prevent PHP warnings "Undefined variable" in dba_pdo::q();
This commit is contained in:
parent
509844fd7e
commit
4bf0c9e36a
@ -66,6 +66,7 @@ class dba_pdo extends dba_driver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result = null;
|
||||||
$this->error = '';
|
$this->error = '';
|
||||||
$select = ((stripos($sql, 'select') === 0) ? true : false);
|
$select = ((stripos($sql, 'select') === 0) ? true : false);
|
||||||
|
|
||||||
|
@ -164,4 +164,26 @@ class dba_pdoTest extends DatabaseTestCase {
|
|||||||
$this->assertFalse($nodba->q('SELECT * FROM account'));
|
$this->assertFalse($nodba->q('SELECT * FROM account'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testConnectToSqlServer
|
||||||
|
*/
|
||||||
|
public function testSelectQueryToNonExistentTableShouldReturnFalse() {
|
||||||
|
$ret = $this->dba->q('SELECT * FROM non_existent_table');
|
||||||
|
|
||||||
|
$this->assertFalse($ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testConnectToSqlServer
|
||||||
|
*/
|
||||||
|
public function testInsertQueryToNonExistentTableShouldReturnEmptyArray() {
|
||||||
|
$ret = $this->dba->q('INSERT INTO non_existent_table
|
||||||
|
(account_email, account_language)
|
||||||
|
VALUES (\'email@example.com\', \'en\')
|
||||||
|
');
|
||||||
|
|
||||||
|
$this->assertNotInstanceOf('PDOStatement', $ret);
|
||||||
|
$this->isEmpty($ret);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user