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

[REF] [Test] Minor simplification on test #18019

Merged
merged 1 commit into from
Aug 2, 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
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