X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fapi%2Fv3%2FParticipantPaymentTest.php;h=e5fe10b82c7c5e5944a20da5fc8b55b9be4da72b;hb=cd17b6d6bf458960c5255721539dcffcc8ee412c;hp=c841b988c0d19a47b46ee7b44a21c7b6775eadaa;hpb=8e570fd74e2dbe7844db5c2cd561541caf5701b0;p=civicrm-core.git diff --git a/tests/phpunit/api/v3/ParticipantPaymentTest.php b/tests/phpunit/api/v3/ParticipantPaymentTest.php index c841b988c0..e5fe10b82c 100644 --- a/tests/phpunit/api/v3/ParticipantPaymentTest.php +++ b/tests/phpunit/api/v3/ParticipantPaymentTest.php @@ -3,7 +3,7 @@ * +--------------------------------------------------------------------+ * | CiviCRM version 4.7 | * +--------------------------------------------------------------------+ - * | Copyright CiviCRM LLC (c) 2004-2016 | + * | Copyright CiviCRM LLC (c) 2004-2017 | * +--------------------------------------------------------------------+ * | This file is a part of CiviCRM. | * | | @@ -123,6 +123,27 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $this->contributionDelete($contributionID); } + /** + * Test getPaymentInfo() returns correct + * information of the participant payment + */ + public function testPaymentInfoForEvent() { + //Create Contribution & get contribution ID + $contributionID = $this->contributionCreate(array('contact_id' => $this->_contactID)); + + //Create Participant Payment record With Values + $params = array( + 'participant_id' => $this->_participantID4, + 'contribution_id' => $contributionID, + ); + $this->callAPISuccess('participant_payment', 'create', $params); + + //Check if participant payment is correctly retrieved. + $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_participantID4, 'event'); + $this->assertEquals('Completed', $paymentInfo['contribution_status']); + $this->assertEquals('100.00', $paymentInfo['total']); + } + ///////////////// civicrm_participant_payment_create methods @@ -393,4 +414,26 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $this->assertDBCompareValues('CRM_Financial_DAO_FinancialItem', $fitemParams, $compareParams); } + /** + * test getParticipantIds() function + */ + public function testGetParticipantIds() { + $contributionID = $this->contributionCreate(array('contact_id' => $this->_contactID)); + $expectedParticipants = array($this->_participantID, $this->_participantID2); + + //Create Participant Payment record With Values + foreach ($expectedParticipants as $pid) { + $params = array( + 'participant_id' => $pid, + 'contribution_id' => $contributionID, + ); + $this->callAPISuccess('participant_payment', 'create', $params); + } + //Check if all participants are listed. + $participants = CRM_Event_BAO_Participant::getParticipantIds($contributionID); + $this->checkArrayEquals($expectedParticipants, $participants); + //delete created contribution + $this->contributionDelete($contributionID); + } + }