CRM-16523 refactor completetransation to call hooks
[civicrm-core.git] / tests / phpunit / api / v3 / ContributionTest.php
index 12661a81e7b68bc24140d2c5b4a9178939b25aec..5d16b62dc4574e26a5ab36bbb14e41be27307b5c 100644 (file)
@@ -1563,10 +1563,29 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
    */
   public function testCompleteTransactionMembershipPriceSet() {
     $this->createPriceSetWithPage('membership');
+    $stateOfGrace = $this->callAPISuccess('MembershipStatus', 'getvalue', array(
+      'name' => 'Grace',
+      'return' => 'id')
+    );
     $this->setUpPendingContribution($this->_ids['price_field_value'][0]);
+    $membership = $this->callAPISuccess('membership', 'getsingle', array('id' => $this->_ids['membership']));
+    $logs = $this->callAPISuccess('MembershipLog', 'get', array(
+      'membership_id' => $this->_ids['membership'],
+    ));
+    $this->assertEquals(1, $logs['count']);
+    $this->assertEquals($stateOfGrace, $membership['status_id']);
     $this->callAPISuccess('contribution', 'completetransaction', array('id' => $this->_ids['contribution']));
     $membership = $this->callAPISuccess('membership', 'getsingle', array('id' => $this->_ids['membership']));
     $this->assertEquals(date('Y-m-d', strtotime('yesterday + 1 year')), $membership['end_date']);
+    $this->callAPISuccessGetSingle('LineItem', array(
+      'entity_id' => $this->_ids['membership'],
+      'entity_table' => 'civicrm_membership',
+    ));
+    $logs = $this->callAPISuccess('MembershipLog', 'get', array(
+      'membership_id' => $this->_ids['membership'],
+    ));
+    $this->assertEquals(2, $logs['count']);
+    $this->assertNotEquals($stateOfGrace, $logs['values'][2]['status_id']);
     $this->cleanUpAfterPriceSets();
   }
 
@@ -1661,6 +1680,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
       'membership_type_id' => $this->_ids['membership_type'],
       'start_date' => 'yesterday - 1 year',
       'end_date' => 'yesterday',
+      'join_date' => 'yesterday - 1 year',
     ));
     $contribution = $this->callAPISuccess('contribution', 'create', array(
       'domain_id' => 1,
@@ -1916,8 +1936,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
   }
 
   /**
-   * @param $contribution
-   * @param $context
+   * @param array $contribution
+   * @param string $context
    * @param int $instrumentId
    */
   public function _checkFinancialTrxn($contribution, $context, $instrumentId = NULL) {