],
],
];
- $order = $this->callAPISuccess('Order', 'create', $orderCreateParams, __FUNCTION__, __FILE__);
+ $order = $this->callAPISuccess('Order', 'create', $orderCreateParams);
// Create expected dates immediately before order creation to minimise chance of day changing over.
//$expectedStart = date('Y-m-d'); $expectedEnd = date('Y-m-d', strtotime('+ 1 year - 1 day'));
* @throws \CRM_Core_Exception
*/
public function testAddOrderForParticipant(): void {
- $event = $this->eventCreate();
- $eventId = $event['id'];
+ $this->eventCreatePaid();
$p = [
'contact_id' => $this->_individualId,
'receive_date' => '2010-01-20',
'line_item' => $lineItems,
'params' => [
'contact_id' => $this->_individualId,
- 'event_id' => $eventId,
+ 'event_id' => $this->getEventID(),
'role_id' => 1,
'register_date' => '2007-07-21 00:00:00',
'source' => 'Online Event Registration: API Testing',
// Enable the "Pending from approval" status which is not enabled by default
$pendingFromApprovalParticipantStatus = civicrm_api3('ParticipantStatusType', 'getsingle', [
- 'name' => "Pending from approval",
+ 'name' => 'Pending from approval',
]);
civicrm_api3('ParticipantStatusType', 'create', [
'id' => $pendingFromApprovalParticipantStatus['id'],
- 'name' => "Pending from approval",
+ 'name' => 'Pending from approval',
'is_active' => 1,
]);
'line_item' => $lineItems,
'params' => [
'contact_id' => $this->individualCreate(),
- 'event_id' => $eventId,
+ 'event_id' => $this->getEventID(),
'role_id' => 1,
'register_date' => '2007-07-21 00:00:00',
'source' => 'Online Event Registration: API Testing',
*/
protected $participantID4;
- /**
- * @var int
- */
- protected $eventID;
-
/**
* Set up for tests.
*/
public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
- $event = $this->eventCreate();
- $this->eventID = $event['id'];
+ $this->eventCreatePaid();
$this->contactID = $this->individualCreate();
$this->individualCreate();
$this->participantID = $this->participantCreate([
- 'contactID' => $this->contactID,
- 'eventID' => $this->eventID,
+ 'contact_id' => $this->contactID,
+ 'event_id' => $this->getEventID(),
]);
$contactID2 = $this->individualCreate();
$this->participantID2 = $this->participantCreate([
- 'contactID' => $contactID2,
- 'eventID' => $this->eventID,
+ 'contact_id' => $contactID2,
+ 'event_id' => $this->getEventID(),
]);
$this->participantID3 = $this->participantCreate([
- 'contactID' => $contactID2,
- 'eventID' => $this->eventID,
+ 'contact_id' => $contactID2,
+ 'event_id' => $this->getEventID(),
]);
$this->contactID3 = $this->individualCreate();
$this->participantID4 = $this->participantCreate([
- 'contactID' => $this->contactID3,
- 'eventID' => $this->eventID,
+ 'contact_id' => $this->contactID3,
+ 'event_id' => $this->getEventID(),
]);
}
* Check with valid array.
*/
public function testPaymentCreate(): void {
- //Create Contribution & get contribution ID
- $contributionID = $this->contributionCreate(['contact_id' => $this->contactID]);
-
- //Create Participant Payment record With Values
- $params = [
+ $this->callAPIAndDocument('ParticipantPayment', 'create', [
'participant_id' => $this->participantID,
- 'contribution_id' => $contributionID,
- ];
-
- $this->callAPIAndDocument('participantPayment', 'create', $params, __FUNCTION__, __FILE__);
+ 'contribution_id' => $this->contributionCreate(['contact_id' => $this->individualCreate()]),
+ ], __FUNCTION__, __FILE__);
}
/**
* Test getPaymentInfo() returns correct
* information of the participant payment
+ *
+ * @throws \CRM_Core_Exception
*/
public function testPaymentInfoForEvent(): void {
//Create Contribution & get contribution ID
/**
* Check financial records for offline Participants.
*/
- public function testPaymentOffline() {
+ public function testPaymentOffline(): void {
// create contribution w/o fee
$contributionID = $this->contributionCreate([
// Update Payment
$participantPayment = $this->callAPISuccess('participantPayment', 'create', $params);
$this->assertEquals($participantPayment['id'], $participantPaymentID);
- $this->assertTrue(array_key_exists('id', $participantPayment));
+ $this->assertArrayHasKey('id', $participantPayment);
// check Financial records
$this->_checkFinancialRecords($params, 'offline');
- $params = [
- 'id' => $participantPaymentID,
- ];
- $deletePayment = $this->callAPISuccess('participantPayment', 'delete', $params);
}
/**
* Check financial records for online Participant.
*/
- public function testPaymentOnline() {
+ public function testPaymentOnline(): void {
$pageParams['processor_id'] = $this->processorCreate();
$contributionPage = $this->contributionPageCreate($pageParams);
// Update Payment
$participantPayment = $this->callAPISuccess('participantPayment', 'create', $params);
$this->assertEquals($participantPayment['id'], $participantPaymentID);
- $this->assertTrue(array_key_exists('id', $participantPayment));
+ $this->assertArrayHasKey('id', $participantPayment);
// check Financial records
$this->_checkFinancialRecords($params, 'online');
- $params = [
- 'id' => $participantPaymentID,
- ];
- $this->callAPISuccess('participantPayment', 'delete', $params);
}
/**
* Check financial records for online Participant pay later scenario.
*/
- public function testPaymentPayLaterOnline() {
+ public function testPaymentPayLaterOnline(): void {
$pageParams['processor_id'] = $this->processorCreate();
$pageParams['is_pay_later'] = 1;
$contributionPage = $this->contributionPageCreate($pageParams);
// check Financial Records
$this->_checkFinancialRecords($params, 'payLater');
$this->assertEquals($participantPayment['id'], $participantPaymentID);
- $this->assertTrue(array_key_exists('id', $participantPayment));
- $params = [
- 'id' => $participantPaymentID,
- ];
- $this->callAPISuccess('participantPayment', 'delete', $params);
+ $this->assertArrayHasKey('id', $participantPayment);
}
/**
- * Check with wrong id.
+ * Check with invalid id.
*/
- public function testPaymentDeleteWithWrongID() {
- $params = [
- 'id' => 0,
- ];
- $deletePayment = $this->callAPIFailure('participantPayment', 'delete', $params);
- $this->assertEquals($deletePayment['error_message'], 'Error while deleting participantPayment');
+ public function testPaymentDeleteWithWrongID(): void {
+ $this->callAPIFailure('ParticipantPayment', 'delete', ['id' => 0], 'Error while deleting participantPayment');
}
/**
* Check with valid array.
*/
- public function testPaymentDelete() {
+ public function testPaymentDelete(): void {
$contributionID = $this->contributionCreate([
'contact_id' => $this->contactID,
]);
/**
* Test civicrm_participantPayment_get - success expected.
*/
- public function testGet() {
+ public function testGet(): void {
$contributionID = $this->contributionCreate(['contact_id' => $this->contactID3]);
$this->participantPaymentCreate($this->participantID4, $contributionID);
* @param array $params
* @param $context
*/
- public function _checkFinancialRecords($params, $context) {
+ public function _checkFinancialRecords($params, $context): void {
$entityParams = [
'entity_id' => $params['id'],
'entity_table' => 'civicrm_contribution',
'financial_account_id' => 1,
];
}
- elseif ($context == 'payLater') {
+ elseif ($context === 'payLater') {
$compareParams = [
'amount' => 100,
'status_id' => 3,
/**
* test getParticipantIds() function
*/
- public function testGetParticipantIds() {
+ public function testGetParticipantIDs(): void {
$contributionID = $this->contributionCreate(['contact_id' => $this->contactID]);
$expectedParticipants = [$this->participantID, $this->participantID2];