class CRM_Contact_Form_Search_Custom_PriceSetTest extends CiviUnitTestCase {
public function testRunSearch() {
- $order = $this->callAPISuccess('Order', 'create', $this->getParticipantOrderParams());
+ $event = $this->eventCreate();
+ $order = $this->callAPISuccess('Order', 'create', $this->getParticipantOrderParams($event['id']));
$this->callAPISuccess('Payment', 'create', [
'order_id' => $order['id'],
'total_amount' => 50,
]);
$this->validateAllPayments();
- $formValues = ['event_id' => $this->_eventId];
+ $formValues = ['event_id' => $event['id']];
$form = new CRM_Contact_Form_Search_Custom_PriceSet($formValues);
$sql = $form->all();
// Assert that we have created a standard temp table
/**
* Get parameters to set up a multi-line participant order.
*
+ * @param null|int $eventId
+ * Optional event ID. A new event will be created if no event ID is given.
* @return array
* @throws \CRM_Core_Exception
*/
- protected function getParticipantOrderParams(): array {
- $event = $this->eventCreate();
- $this->_eventId = $event['id'];
+ protected function getParticipantOrderParams($eventId = NULL): array {
+ if (!$eventId) {
+ $event = $this->eventCreate();
+ $eventId = $event['id'];
+ }
+
$eventParams = [
- 'id' => $this->_eventId,
+ 'id' => $eventId,
'financial_type_id' => 4,
'is_monetary' => 1,
];
$this->callAPISuccess('event', 'create', $eventParams);
- $priceFields = $this->createPriceSet('event', $this->_eventId);
+ $priceFields = $this->createPriceSet('event', $eventId);
$orderParams = [
'total_amount' => 300,
'currency' => 'USD',
],
'params' => [
'financial_type_id' => 4,
- 'event_id' => $this->_eventId,
+ 'event_id' => $eventId,
'role_id' => 1,
'status_id' => 14,
'fee_currency' => 'USD',