@@ -657,7 +657,7 @@ public function testSubmitPartialPayment($thousandSeparator) {
657
657
$ this ->createLoggedInUser ();
658
658
$ priceSet = $ this ->callAPISuccess ('PriceSet ' , 'Get ' , ["extends " => "CiviMember " ]);
659
659
$ form ->set ('priceSetId ' , $ priceSet ['id ' ]);
660
- $ partiallyPaidAmount = 25 ;
660
+
661
661
CRM_Price_BAO_PriceSet::buildPriceSet ($ form );
662
662
$ params = [
663
663
'cid ' => $ this ->_individualId ,
@@ -668,9 +668,9 @@ public function testSubmitPartialPayment($thousandSeparator) {
668
668
'membership_type_id ' => [23 , $ this ->membershipTypeAnnualFixedID ],
669
669
'receive_date ' => date ('Y-m-d ' , time ()) . ' 20:36:00 ' ,
670
670
'record_contribution ' => 1 ,
671
- 'total_amount ' => $ this ->formatMoneyInput ($ partiallyPaidAmount ),
672
- 'payment_instrument_id ' => array_search ('Check ' , $ this ->paymentInstruments ),
673
- 'contribution_status_id ' => CRM_Core_PseudoConstant::getKey ('CRM_Contribute_BAO_Contribution ' , 'contribution_status_id ' , 'Partially paid ' ),
671
+ 'total_amount ' => $ this ->formatMoneyInput (50 ),
672
+ 'payment_instrument_id ' => array_search ('Check ' , $ this ->paymentInstruments , TRUE ),
673
+ 'contribution_status_id ' => CRM_Core_PseudoConstant::getKey ('CRM_Contribute_BAO_Contribution ' , 'contribution_status_id ' , 'Pending ' ),
674
674
//Member dues, see data.xml
675
675
'financial_type_id ' => '2 ' ,
676
676
'payment_processor_id ' => $ this ->_paymentProcessorID ,
@@ -679,41 +679,39 @@ public function testSubmitPartialPayment($thousandSeparator) {
679
679
$ form ->testSubmit ($ params );
680
680
$ membership = $ this ->callAPISuccessGetSingle ('Membership ' , ['contact_id ' => $ this ->_individualId ]);
681
681
// check the membership status after partial payment, if its Pending
682
- $ this ->assertEquals (array_search ('Pending ' , CRM_Member_PseudoConstant::membershipStatus ()), $ membership ['status_id ' ]);
683
- $ contribution = $ this ->callAPISuccessGetSingle ('Contribution ' , [
684
- ' contact_id ' => $ this -> _individualId ,
685
- ]);
682
+ $ this ->assertEquals (array_search ('Pending ' , CRM_Member_PseudoConstant::membershipStatus (), TRUE ), $ membership ['status_id ' ]);
683
+ $ contribution = $ this ->callAPISuccessGetSingle ('Contribution ' , [' contact_id ' => $ this -> _individualId ]);
684
+ $ this -> callAPISuccess ( ' Payment ' , ' create ' , [ ' contribution_id ' => $ contribution [ ' id ' ], ' total_amount ' => 25 , ' payment_instrument_id ' => ' Cash ' ]);
685
+ $ contribution = $ this -> callAPISuccessGetSingle ( ' Contribution ' , [ ' id ' => $ contribution [ ' id ' ] ]);
686
686
$ this ->assertEquals ('Partially paid ' , $ contribution ['contribution_status ' ]);
687
- // $this->assertEquals(50.00, $contribution['total_amount']);
688
- // $this->assertEquals(25.00, $contribution['net_amount']);
689
687
690
688
// Step 2: submit the other half of the partial payment
691
689
// via AdditionalPayment form to complete the related contribution
692
690
$ form = new CRM_Contribute_Form_AdditionalPayment ();
693
691
$ submitParams = [
694
692
'contribution_id ' => $ contribution ['contribution_id ' ],
695
693
'contact_id ' => $ this ->_individualId ,
696
- 'total_amount ' => $ this ->formatMoneyInput ($ partiallyPaidAmount ),
694
+ 'total_amount ' => $ this ->formatMoneyInput (25 ),
697
695
'currency ' => 'USD ' ,
698
696
'financial_type_id ' => 2 ,
699
697
'receive_date ' => '2015-04-21 23:27:00 ' ,
700
698
'trxn_date ' => '2017-04-11 13:05:11 ' ,
701
699
'payment_processor_id ' => 0 ,
702
- 'payment_instrument_id ' => array_search ('Check ' , $ this ->paymentInstruments ),
700
+ 'payment_instrument_id ' => array_search ('Check ' , $ this ->paymentInstruments , TRUE ),
703
701
'check_number ' => 'check-12345 ' ,
704
702
];
705
703
$ form ->cid = $ this ->_individualId ;
706
704
$ form ->testSubmit ($ submitParams );
707
705
$ membership = $ this ->callAPISuccessGetSingle ('Membership ' , ['contact_id ' => $ this ->_individualId ]);
708
706
// check the membership status after additional payment, if its changed to 'New'
709
- $ this ->assertEquals (array_search ('New ' , CRM_Member_PseudoConstant::membershipStatus ()), $ membership ['status_id ' ]);
707
+ $ this ->assertEquals (array_search ('New ' , CRM_Member_PseudoConstant::membershipStatus (), TRUE ), $ membership ['status_id ' ]);
710
708
711
709
// check the contribution status and net amount after additional payment
712
710
$ contribution = $ this ->callAPISuccessGetSingle ('Contribution ' , [
713
711
'contact_id ' => $ this ->_individualId ,
714
712
]);
715
713
$ this ->assertEquals ('Completed ' , $ contribution ['contribution_status ' ]);
716
- // $this->assertEquals(50.00, $contribution['net_amount'] );
714
+ $ this ->validateAllPayments ( );
717
715
}
718
716
719
717
/**
@@ -724,14 +722,14 @@ public function testSubmitPartialPayment($thousandSeparator) {
724
722
public function testSubmitRecur () {
725
723
CRM_Core_Session::singleton ()->getStatus (TRUE );
726
724
$ pendingVal = $ this ->callAPISuccessGetValue ('OptionValue ' , [
727
- 'return ' => " id " ,
728
- 'option_group_id ' => " contribution_status " ,
729
- 'label ' => " Pending Label** " ,
725
+ 'return ' => ' id ' ,
726
+ 'option_group_id ' => ' contribution_status ' ,
727
+ 'label ' => ' Pending Label** ' ,
730
728
]);
731
729
//Update label for Pending contribution status.
732
730
$ this ->callAPISuccess ('OptionValue ' , 'create ' , [
733
731
'id ' => $ pendingVal ,
734
- 'label ' => " PendingEdited " ,
732
+ 'label ' => ' PendingEdited ' ,
735
733
]);
736
734
737
735
$ form = $ this ->getForm ();
0 commit comments