CRM_Core_DAO::createTestObject() - Prefer BAO's
authorTim Otten <totten@civicrm.org>
Tue, 6 Jan 2015 02:16:13 +0000 (18:16 -0800)
committerTim Otten <totten@civicrm.org>
Wed, 7 Jan 2015 01:07:01 +0000 (17:07 -0800)
CRM/Core/DAO.php

index 2b686b3ecc67af2396b8658d8c65db88889d2b9d..ad7a213312adbb0fb867fe2071ceaf2f517deff2 100644 (file)
@@ -1604,6 +1604,13 @@ SELECT contact_id
       'CRM_Financial_DAO_FinancialType'//because valid ones exist & we use pick them due to pseudoconstant can't reliably create & delete these
     );
 
+    // Prefer to instantiate BAO's instead of DAO's (when possible)
+    // so that assignTestValue()/assignTestFK() can be overloaded.
+    $baoName = str_replace('_DAO_', '_BAO_', $daoName);
+    if (class_exists($baoName)) {
+      $daoName = $baoName;
+    }
+
     for ($i = 0; $i < $numObjects; ++$i) {
 
       ++$counter;