Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests to use buildFeeFn #16389

Merged
merged 2 commits into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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