Skip to content

Commit

Permalink
Merge pull request #18019 from eileenmcnaughton/event_clean
Browse files Browse the repository at this point in the history
[REF] [Test] Minor simplification on test
  • Loading branch information
seamuslee001 authored Aug 2, 2020
2 parents 5f38639 + 57a7aa8 commit ddaa955
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ public function testAssignProportionalLineItems() {
/**
* Add participant with contribution
*
* @return array
* @return CRM_Contribute_BAO_Contribution
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
Expand All @@ -695,7 +695,7 @@ public function addParticipantWithContribution() {
$this->_contactId = $this->individualCreate();
$event = $this->eventCreatePaid([]);
$this->_eventId = $event['id'];
$priceSetId = $this->priceSetID;
$priceSetID = $this->ids['PriceSet']['event'];
$paramsField = [
'label' => 'Price Field',
'name' => CRM_Utils_String::titleToVar('Price Field'),
Expand All @@ -709,7 +709,7 @@ public function addParticipantWithContribution() {
'weight' => 1,
'options_per_line' => 1,
'is_active' => ['1' => 1, '2' => 1],
'price_set_id' => $this->priceSetID,
'price_set_id' => $priceSetID,
'is_enter_qty' => 1,
'financial_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', 'Event Fee', 'id', 'name'),
];
Expand All @@ -720,7 +720,7 @@ public function addParticipantWithContribution() {
'is_monetary' => 1,
];
CRM_Event_BAO_Event::create($eventParams);
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceSetId);
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceSetID);

$priceFields = $this->callAPISuccess('PriceFieldValue', 'get', ['price_field_id' => $priceField->id]);
$participantParams = [
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Event/Form/ParticipantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ public function testTransferParticipantRegistration() {
* @return int
*/
protected function getEventID(): int {
return $this->ids['event']['event'];
return $this->ids['Event']['event'];
}

/**
Expand Down
11 changes: 6 additions & 5 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1054,12 +1054,13 @@ public function eventCreate($params = []) {
* @throws \CRM_Core_Exception
*/
protected function eventCreatePaid($params, $options = [['name' => 'hundy', 'amount' => 100]], $key = 'event') {
$params['is_monetary'] = TRUE;
$event = $this->eventCreate($params);
$this->ids['event'][$key] = (int) $event['id'];
$this->priceSetID = $this->ids['PriceSet'][] = $this->eventPriceSetCreate(55, 0, 'Radio', $options);
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $event['id'], $this->priceSetID);
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($this->priceSetID, TRUE, FALSE);
$priceSet = $priceSet[$this->priceSetID] ?? NULL;
$this->ids['Event'][$key] = (int) $event['id'];
$this->ids['PriceSet'][$key] = $this->eventPriceSetCreate(55, 0, 'Radio', $options);
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $event['id'], $this->ids['PriceSet'][$key]);
$priceSet = CRM_Price_BAO_PriceSet::getSetDetail($this->ids['PriceSet'][$key], TRUE, FALSE);
$priceSet = $priceSet[$this->ids['PriceSet'][$key]] ?? NULL;
$this->eventFeeBlock = $priceSet['fields'] ?? NULL;
return $event;
}
Expand Down

0 comments on commit ddaa955

Please sign in to comment.