minor tidy ups
authorEileen McNaughton <eileen@fuzion.co.nz>
Sun, 19 Oct 2014 08:15:53 +0000 (21:15 +1300)
committerEileen McNaughton <eileen@fuzion.co.nz>
Sun, 19 Oct 2014 08:15:53 +0000 (21:15 +1300)
tests/phpunit/CiviTest/CiviUnitTestCase.php

index f8959c8da9b63ed6e35a610b8be47ac4b67ddd27..f007c512026a02335a172f5ecea70e69c56fb3e9 100644 (file)
@@ -1901,7 +1901,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     }
 
     //have a crack @ deleting it first in the hope this will prevent derailing our tests
-    $check = $this->callAPISuccess('custom_group', 'get', array('title' => $params['title'], array('api.custom_group.delete' => 1)));
+    $this->callAPISuccess('custom_group', 'get', array('title' => $params['title'], array('api.custom_group.delete' => 1)));
 
     return $this->callAPISuccess('custom_group', 'create', $params);
   }
@@ -2936,6 +2936,7 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
    $result = $this->callAPISuccess('payment_processor', 'create', $params);
    return $result['id'];
  }
+
   /**
    * Set up initial recurring payment allowing subsequent IPN payments
    */
@@ -2964,12 +2965,31 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
     $this->_contributionID = $contributionRecur['values']['0']['api.contribution.create']['id'];
   }
 
+  /**
+   * we don't have a good way to set up a recurring contribution with a membership so let's just do one then alter it
+   */
+  function setupMembershipRecurringPaymentProcessorTransaction() {
+    $this->setupRecurringPaymentProcessorTransaction();
+    $this->ids['membership_type'] = $this->membershipTypeCreate();
+    $this->ids['membership'] = $this->callAPISuccess('membership', 'create', array(
+      'contact_id' => $this->_contactID,
+      'membership_type_id' => $this->ids['membership_type'],
+      'contribution_recur_id' => $this->_contributionRecurID,
+      'api.membership_payment.create' => array('contribution_id' => $this->_contributionID),
+      'format.only_id' => TRUE,
+    ));
+    CRM_Core_DAO::executeQuery(
+      "UPDATE civicrm_line_item SET entity_table = 'civicrm_membership', entity_id = {$this->ids['membership']}
+      WHERE entity_id = {$this->_contributionID} AND entity_table = 'civicrm_contribution'"
+    );
+  }
 
   /**
    * @param $message
    *
    * @throws Exception
-   */function CiviUnitTestCase_fatalErrorHandler($message) {
-  throw new Exception("{$message['message']}: {$message['code']}");
-}
+   */
+  function CiviUnitTestCase_fatalErrorHandler($message) {
+    throw new Exception("{$message['message']}: {$message['code']}");
+  }
 }