From: Seamus Lee Date: Sun, 28 Aug 2016 23:55:50 +0000 (+1000) Subject: Update transaction test to run against core and to work on either mysql or mysqli... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9b65c036a01371649c813351c062ec214abd1047;p=civicrm-core.git Update transaction test to run against core and to work on either mysql or mysqli depending on what the dsn setting is --- diff --git a/tests/phpunit/CRM/Core/TransactionTest.php b/tests/phpunit/CRM/Core/TransactionTest.php index 60a9312284..a589c932e2 100644 --- a/tests/phpunit/CRM/Core/TransactionTest.php +++ b/tests/phpunit/CRM/Core/TransactionTest.php @@ -362,7 +362,16 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { if ($insert == 'sql-insert') { $r = CRM_Core_DAO::executeQuery("INSERT INTO civicrm_contact(first_name,last_name) VALUES ('ff', 'll')"); - $cid = mysqli_insert_id($r->getConnection()->connection); + $mysqlFunction = strstr(CRM_Core_Config::singleton()->dsn, 'mysqli') ? 'mysqli_insert_id' : 'mysql_insert_id'; + if ($mysqlFunction == 'mysql_insert_id' && phpversion() >= 7) { + CRM_Core_Exception('Current DSN in compatible with the PHP version, need to update to use mysqli'); + } + if ($mysqlFunction == 'mysqli_insert_id') { + $cid = mysqli_insert_id($r->getConnection()->connection); + } + else { + $cid = mysql_insert_id(); + } } elseif ($insert == 'bao-create') { $params = array(