Skip to content

Commit

Permalink
[REF] [Test] Minor simplification on test
Browse files Browse the repository at this point in the history
This is towards standardising on one way to reference created entities -ie

->ids['Participant'][key] = 4
  • Loading branch information
eileenmcnaughton committed Aug 1, 2020
1 parent eae974d commit 5e9656b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 5e9656b

Please sign in to comment.