Skip to content

Commit

Permalink
Merge pull request #16389 from eileenmcnaughton/ev_static
Browse files Browse the repository at this point in the history
Fix tests to use buildFeeFn
  • Loading branch information
seamuslee001 authored Jan 27, 2020
2 parents 8fc4a86 + 34dee1d commit c2009ff
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
19 changes: 16 additions & 3 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@
*/
class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment {

/**
* Participant ID - use getParticipantID.
*
* @var int
*/
public $_pId;

/**
* ID of discount record.
*
* @var int
*/
public $_discountId;

public $useLivePageJS = TRUE;

/**
Expand Down Expand Up @@ -1669,7 +1683,7 @@ public function buildEventFeeForm($form) {
$form->addElement('hidden', 'hidden_feeblock', 1);
}

$eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $form->_pId);
$eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $this->getParticipantID());
$form->addElement('hidden', 'hidden_eventFullMsg', $eventfullMsg, ['id' => 'hidden_eventFullMsg']);
}

Expand Down Expand Up @@ -1811,7 +1825,6 @@ public function buildEventFeeForm($form) {
*
* @return array
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
protected function preparePaidEventProcessing($params): array {
Expand Down Expand Up @@ -2212,7 +2225,7 @@ protected function getParticipantValue($fieldName) {
* @return int|null
*/
protected function getParticipantID() {
return $this->_id;
return $this->_id ?? $this->_pId;
}

}
14 changes: 13 additions & 1 deletion tests/phpunit/CRM/Event/Form/ParticipantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ public function setUp() {
parent::setUp();
}

/**
* CHeck that all tests that have created payments have created them with the right financial entities.
*
* Ideally this would be on CiviUnitTestCase but many classes would still fail. Also, it might
* be good if it only ran on tests that created at least one contribution.
*
* @throws \CRM_Core_Exception
*/
protected function assertPostConditions() {
$this->validateAllPayments();
}

/**
* Initial test of submit function.
*
Expand Down Expand Up @@ -316,8 +328,8 @@ protected function getForm($eventParams = []) {
$form->_eventId = $event['id'];
if (!empty($eventParams['is_monetary'])) {
$form->_bltID = 5;
$form->_values['fee'] = [];
$form->_isPaidEvent = TRUE;
$form->buildEventFeeForm($form);
}
return $form;
}
Expand Down

0 comments on commit c2009ff

Please sign in to comment.