From 4bf0c9e36a4a89d6b84c6bf8a74124603add9d9e Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Mon, 22 Jan 2018 22:59:13 +0100 Subject: :white_check_mark: Add tests for non existent tables. Prevent PHP warnings "Undefined variable" in dba_pdo::q(); --- tests/unit/includes/dba/dba_pdoTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/unit/includes/dba/dba_pdoTest.php b/tests/unit/includes/dba/dba_pdoTest.php index ce6e1ffd6..12e574d42 100644 --- a/tests/unit/includes/dba/dba_pdoTest.php +++ b/tests/unit/includes/dba/dba_pdoTest.php @@ -164,4 +164,26 @@ class dba_pdoTest extends DatabaseTestCase { $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); + } + } -- cgit v1.2.3