useTransaction(TRUE); $this->_individualId = $this->individualCreate(); $contributionParams = array( 'contact_id' => $this->_individualId, 'receive_date' => '20120511', 'total_amount' => 100.00, 'financial_type_id' => $this->_financialTypeId, 'non_deductible_amount' => 10.00, 'fee_amount' => 51.00, 'net_amount' => 91.00, 'source' => 'SSF', 'contribution_status_id' => 1, ); $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams); $this->params = array( 'price_field_value_id' => 1, 'price_field_id' => 1, 'entity_table' => 'civicrm_contribution', 'entity_id' => $contribution['id'], 'qty' => 1, 'unit_price' => 50, 'line_total' => 50, ); } public function testCreateLineItem() { $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params + array('debug' => 1), __FUNCTION__, __FILE__); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__); $this->getAndCheck($this->params, $result['id'], $this->_entity); } public function testGetBasicLineItem() { $getParams = array( 'entity_table' => 'civicrm_contribution', ); $getResult = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__); $this->assertEquals(1, $getResult['count'], 'In line ' . __LINE__); } public function testDeleteLineItem() { $getParams = array( 'entity_table' => 'civicrm_contribution', ); $getResult = $this->callAPISuccess($this->_entity, 'get', $getParams); $deleteParams = array('id' => $getResult['id']); $deleteResult = $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__); $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array()); $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__); } public function testGetFieldsLineItem() { $result = $this->callAPISuccess($this->_entity, 'getfields', array('action' => 'create')); $this->assertEquals(1, $result['values']['entity_id']['api.required']); } }