Merge pull request #19023 from eileenmcnaughton/tt
authorcolemanw <coleman@civicrm.org>
Tue, 8 Dec 2020 19:29:54 +0000 (14:29 -0500)
committerGitHub <noreply@github.com>
Tue, 8 Dec 2020 19:29:54 +0000 (14:29 -0500)
Extend test to cover membership logs

1  2 
tests/phpunit/api/v3/ContributionTest.php

index d30a117cc754bd3e737f9bffe072892ea0b22602,34f3bcce849d84465a9bb5e2eeb2ff0c90f83eb3..3a434ecb71c59e626894c45c70ee23f98cc2c71d
@@@ -3432,9 -3432,14 +3432,14 @@@ class api_v3_ContributionTest extends C
    }
  
    /**
-    * Test if renewal activity is create after changing Pending contribution to Completed via offline
+    * Test if renewal activity is create after changing Pending contribution to
+    * Completed via offline
+    *
+    * @throws \CRM_Core_Exception
+    * @throws \CRM_Core_Exception
+    * @throws \CiviCRM_API3_Exception
     */
-   public function testPendingToCompleteContribution() {
+   public function testPendingToCompleteContribution(): void {
      $this->createPriceSetWithPage('membership');
      $this->setUpPendingContribution($this->_ids['price_field_value'][0]);
      $this->callAPISuccess('membership', 'getsingle', ['id' => $this->_ids['membership']]);
      ]);
      $this->assertEquals(1, $activity['count']);
      $this->assertEquals('Status changed from Grace to Current', $activity['values'][$activity['id']]['subject']);
+     $membershipLogs = $this->callAPISuccess('MembershipLog', 'get', ['sequential' => 1])['values'];
+     $this->assertEquals('Grace', CRM_Core_PseudoConstant::getName('CRM_Member_BAO_Membership', 'status_id', $membershipLogs[0]['status_id']));
+     $this->assertEquals('Current', CRM_Core_PseudoConstant::getName('CRM_Member_BAO_Membership', 'status_id', $membershipLogs[1]['status_id']));
      //Create another pending contribution for renewal
      $contribution = $this->callAPISuccess('contribution', 'create', [
        'domain_id' => 1,
      $form->testSubmit($form->_params, CRM_Core_Action::UPDATE);
      //Existing membership should not get updated to expired.
      $membership = $this->callAPISuccess('membership', 'getsingle', ['id' => $this->_ids['membership']]);
-     $this->assertNotEquals($membership['status_id'], 4);
+     $this->assertNotEquals(4, $membership['status_id']);
    }
  
    /**
      ], [
        'Event',
      ]);
 -    $this->checkReceiptDetails($mut, $contributionPage['id'], $contribution['id']);
 +    $this->checkReceiptDetails($mut, $contributionPage['id'], $contribution['id'], $pageParams);
      $mut->stop();
    }
  
     * @param CiviMailUtils $mut
     * @param int $pageID Page ID
     * @param int $contributionID Contribution ID
 +   * @param array $pageParams
     *
     * @throws \CRM_Core_Exception
     */
 -  public function checkReceiptDetails($mut, $pageID, $contributionID) {
 +  public function checkReceiptDetails($mut, $pageID, $contributionID, $pageParams) {
      $pageReceipt = [
        'receipt_from_name' => "Page FromName",
        'receipt_from_email' => "page_from@email.com",
        'cc_receipt' => "page_cc@email.com",
        'receipt_text' => "Page Receipt Text",
 +      'pay_later_receipt' => $pageParams['pay_later_receipt'],
      ];
      $customReceipt = [
        'receipt_from_name' => "Custom FromName",
        'receipt_from_email' => "custom_from@email.com",
        'cc_receipt' => "custom_cc@email.com",
        'receipt_text' => "Test Custom Receipt Text",
 +      'pay_later_receipt' => 'Mail your check to test@example.com within 3 business days.',
      ];
      $this->callAPISuccess('ContributionPage', 'create', array_merge([
        'id' => $pageID,
      ], $customReceipt));
  
      //Verify if custom receipt details are present in email.
 +    //Page receipt details shouldn't be included.
      $mut->checkMailLog(array_values($customReceipt), array_values($pageReceipt));
    }