From b63480e332bcb8f0e76536f4e38b08d1121d14c4 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Fri, 12 Feb 2016 10:04:06 +0530 Subject: [PATCH] --CRM-16188, added test to check transitioncomponent function --- tests/phpunit/api/v3/OrderTest.php | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/phpunit/api/v3/OrderTest.php b/tests/phpunit/api/v3/OrderTest.php index 8934970f0d..6853a0fa29 100644 --- a/tests/phpunit/api/v3/OrderTest.php +++ b/tests/phpunit/api/v3/OrderTest.php @@ -481,4 +481,56 @@ class api_v3_OrderTest extends CiviUnitTestCase { )); } + /** + * 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'], + )); + } + } -- 2.25.1