));
}
+ /**
+ * Test cancel order api
+ */
+ public function testCancelWithParticipant() {
+ $this->_eventId = Event::create($this->_individualId);
+ $eventParams = array(
+ 'id' => $this->_eventId,
+ 'financial_type_id' => 4,
+ 'is_monetary' => 1,
+ );
+ $this->callAPISuccess('event', 'create', $eventParams);
+ $participantParams = array(
+ 'financial_type_id' => 4,
+ 'event_id' => $this->_eventId,
+ 'role_id' => 1,
+ 'status_id' => 1,
+ 'fee_currency' => 'USD',
+ 'contact_id' => $this->_individualId,
+ );
+ $participant = $this->callAPISuccess('Participant', 'create', $participantParams);
+ $extraParams = array(
+ 'contribution_mode' => 'participant',
+ 'participant_id' => $participant['id'],
+ );
+ $contribution = $this->addOrder(TRUE, 100, $extraParams);
+ $paymentParticipant = array(
+ 'participant_id' => $participant['id'],
+ 'contribution_id' => $contribution['id'],
+ );
+ $this->callAPISuccess('ParticipantPayment', 'create', $paymentParticipant);
+ $params = array(
+ 'contribution_id' => $contribution['id'],
+ );
+ $this->callAPISuccess('order', 'cancel', $params);
+ $order = $this->callAPISuccess('Order', 'get', $params);
+ $expectedResult = array(
+ $contribution['id'] => array(
+ 'total_amount' => 100,
+ 'contribution_id' => $contribution['id'],
+ 'contribution_status' => 'Cancelled',
+ 'net_amount' => 100,
+ ),
+ );
+ $this->checkPaymentResult($order, $expectedResult);
+ $participantPayment = $this->callAPISuccess('ParticipantPayment', 'getsingle', $params);
+ $participant = $this->callAPISuccess('participant', 'get', array('id' => $participantPayment['participant_id']));
+ $this->assertEquals($participant['values'][$participant['id']]['participant_status'], 'Cancelled');
+ $this->callAPISuccess('Contribution', 'Delete', array(
+ 'id' => $contribution['id'],
+ ));
+ }
+
}