From 360b6a15b0615fdf1c89170dc1b2ed3427e43b5a Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 11 Feb 2019 11:34:58 -0800 Subject: [PATCH] Whitelist specific folders for coverage. More PDO tests. --- codeception.yml | 8 ++++- tests/unit/e_db_pdoTest.php | 66 +++++++++++++++++++++++++++++-------- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/codeception.yml b/codeception.yml index a69896d7f..987d66892 100644 --- a/codeception.yml +++ b/codeception.yml @@ -11,7 +11,13 @@ coverage: enabled: true include: - '%app_path%/*.php' - - '%app_path%/**/*.php' + - '%app_path%/e107_admin/**/*.php' + - '%app_path%/e107_core/**/*.php' + - '%app_path%/e107_handlers/**/*.php' + - '%app_path%/e107_images/**/*.php' + - '%app_path%/e107_plugins/**/*.php' + - '%app_path%/e107_themes/**/*.php' + - '%app_path%/e107_web/**/*.php' params: - lib/config.php extensions: diff --git a/tests/unit/e_db_pdoTest.php b/tests/unit/e_db_pdoTest.php index 5a2d4d7db..387d6a536 100644 --- a/tests/unit/e_db_pdoTest.php +++ b/tests/unit/e_db_pdoTest.php @@ -91,13 +91,21 @@ } /** - * Test primary methods against a secondary database (ensures mysqlPrefix is working correctly) - * TODO Split into separate methods? Order needs to be respected. + * @desc Test primary methods against a secondary database (ensures mysqlPrefix is working correctly) */ - /* public function testSecondaryDatabase() { - $xql = e107::getDb('newdb'); + + try + { + $xql = $this->make('e_db_pdo'); + } + catch (Exception $e) + { + $this->fail("Couldn't load e_db_pdo object"); + } + + $xql->__construct(); $config = e107::getMySQLConfig(); $database = 'e107_tests_tmp'; @@ -183,7 +191,7 @@ // primary database retrieve - $username = e107::getDb()->retrieve('user','user_name', 'user_id = 1'); + $username = $this->db->retrieve('user','user_name', 'user_id = 1'); $this->assertNotEmpty($username, "Lost connection with primary database."); @@ -206,7 +214,7 @@ } -*/ + public function testGetServerInfo() @@ -494,6 +502,17 @@ } */ + public function testDb_QueryCount() + { + $this->db->select('user', '*'); + $this->db->select('plugin','*'); + + $result = $this->db->db_QueryCount(); + $this->assertEquals(2,$result); + + } + + public function testDb_UpdateArray() { @@ -716,10 +735,16 @@ } */ - public function testIsTable() + public function testDb_Table_exists() { - $result = $this->db->isTable('plugin'); + $result = $this->db->db_Table_exists('plugin'); $this->assertTrue($result); + + $result = $this->db->db_Table_exists('plugin', 'French'); + $this->assertFalse($result); + + $result = $this->db->db_Table_exists('plugin', 'English'); + $this->assertFalse($result); } public function testIsEmpty() @@ -727,17 +752,29 @@ $result = $this->db->isEmpty('plugin'); $this->assertFalse($result); } -/* + public function testDb_ResetTableList() { - + $this->db->Db_ResetTableList(); } public function testDb_TableList() { + $list = $this->db->db_TableList(); + + $present = in_array('banlist', $list); + $this->assertTrue($present); + + $list = $this->db->db_TableList('nologs'); + $present = in_array('admin_log', $list); + $this->assertFalse($present); + + $list = $this->db->db_TableList('lan'); + $this->assertEmpty($list); + //var_dump($list); } -*/ + public function testTables() { $list = $this->db->tables(); @@ -823,14 +860,15 @@ { } +*/ - public function testDb_Set_Charset() + public function testDb_ResetTableList() { - + $this->db->db_ResetTableList(); } public function testGetFieldDefs() { - }*/ + } }