Fix Syntax Conformance Tests (#2)
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 11 Oct 2016 12:32:47 +0000 (23:32 +1100)
committercolemanw <coleman@civicrm.org>
Tue, 11 Oct 2016 12:32:47 +0000 (08:32 -0400)
Civi/API/SelectQuery.php
api/v3/utils.php
tests/phpunit/api/v3/SyntaxConformanceTest.php

index 44c347c64b0752c8a5944d3558b1f5ab8e18bb4a..fc5d22cad5b5ed3ce4d191ffdc36300137a55c06 100644 (file)
@@ -123,8 +123,7 @@ abstract class SelectQuery {
     $this->buildSelectFields();
 
     $this->buildWhereClause();
-
-    if (in_array('count', $this->select)) {
+    if (in_array('count_rows', $this->select)) {
       $this->query->select("count(*) as c");
     }
     else {
@@ -144,7 +143,7 @@ abstract class SelectQuery {
     $result_dao = \CRM_Core_DAO::executeQuery($this->query->toSQL());
 
     while ($result_dao->fetch()) {
-      if (in_array('count', $this->select)) {
+      if (in_array('count_rows', $this->select)) {
         $result_dao->free();
         return (int) $result_dao->c;
       }
index e48f6a52cb2ac89d186c6842445fa41fd81b0ffc..ba7393aebab34fc8c7aaf964e93d77812fdd73a6 100644 (file)
@@ -176,13 +176,8 @@ function civicrm_api3_create_success($values = 1, $params = array(), $entity = N
         $values[$key]['id'] = $item[$lowercase_entity . "_id"];
       }
       if (!empty($item['financial_type_id'])) {
-        // 4.3 legacy handling - translate financial_type to contribution_type unless financial_type is explicitly specified.
-        if (!is_array($params) || empty($params['return']) || !is_array($params['return']) ||
-          (empty($params['return']['financial_type_id']) && !in_array('financial_type_id', $params['return'])) ||
-          (!empty($params['return']['contribution_type_id']) || in_array('contribution_type_id', $params['return']))
-        ) {
-          $values[$key]['contribution_type_id'] = $item['financial_type_id'];
-        }
+        // 4.3 legacy handling.
+        $values[$key]['contribution_type_id'] = $item['financial_type_id'];
       }
       if (!empty($item['next_sched_contribution_date'])) {
         // 4.4 legacy handling
@@ -1347,7 +1342,7 @@ function _civicrm_api3_basic_get($bao_name, $params, $returnAsSuccess = TRUE, $e
   $query = new \Civi\API\Api3SelectQuery($entity, CRM_Utils_Array::value('check_permissions', $params, FALSE));
   $query->where = $params;
   if ($options['is_count']) {
-    $query->select = array('count');
+    $query->select = array('count_rows');
   }
   else {
     $query->select = array_keys(array_filter($options['return']));
index 238fdea6444ce7ebbdb0b7b2a68c900f152fd9b0..c2f7a25d825ab0032b1196e2b29ecf898b8fe38f 100644 (file)
@@ -1282,6 +1282,10 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
         //api has special handling on these 2 fields for backward compatibility reasons
         $entity['contribution_type_id'] = $updateParams['financial_type_id'];
       }
+      if (isset($updateParams['next_sched_contribution_date']) && in_array($entityName, array('ContributionRecur'))) {
+        //api has special handling on these 2 fields for backward compatibility reasons
+        $entity['next_sched_contribution'] = $updateParams['next_sched_contribution_date'];
+      }
 
       $update = $this->callAPISuccess($entityName, 'create', $updateParams);
       $checkParams = array(
@@ -1312,6 +1316,10 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
           //api has special handling on these 2 fields for backward compatibility reasons
           $entity['contribution_type_id'] = $updateParams['financial_type_id'];
         }
+        if (isset($updateParams['next_sched_contribution_date']) && in_array($entityName, array('ContributionRecur'))) {
+          //api has special handling on these 2 fields for backward compatibility reasons
+          $entity['next_sched_contribution'] = $updateParams['next_sched_contribution_date'];
+        }
       }
     }
     $baoObj->free();