useTransaction(TRUE); } /** * Create a sample batch */ public function batchCreate() { $params = $this->_params; $params['name'] = $params['title'] = 'Batch_433397'; $params['status_id'] = 1; $result = $this->callAPISuccess('batch', 'create', $params); return $result['id']; } /** * Test civicrm_batch_get - success expected. */ public function testGet() { $params = array( 'id' => $this->batchCreate(), ); $result = $this->callAPIAndDocument('batch', 'get', $params, __FUNCTION__, __FILE__); $this->assertEquals($params['id'], $result['id'], 'In line ' . __LINE__); } /** * Test civicrm_batch_create - success expected. */ public function testCreate() { $params = array( 'name' => 'New_Batch_03', 'title' => 'New Batch 03', 'description' => 'This is description for New Batch 03', 'total' => '300.33', 'item_count' => 3, 'status_id' => 1, ); $result = $this->callAPIAndDocument('batch', 'create', $params, __FUNCTION__, __FILE__); $this->assertNotNull($result['id'], 'In line ' . __LINE__); $this->getAndCheck($params, $result['id'], $this->_entity); } /** * Test civicrm_batch_create with id. */ public function testUpdate() { $params = array( 'name' => 'New_Batch_04', 'title' => 'New Batch 04', 'description' => 'This is description for New Batch 04', 'total' => '400.44', 'item_count' => 4, 'id' => $this->batchCreate(), ); $result = $this->callAPIAndDocument('batch', 'create', $params, __FUNCTION__, __FILE__); $this->assertNotNull($result['id'], 'In line ' . __LINE__); $this->getAndCheck($params, $result['id'], $this->_entity); } /** * Test civicrm_batch_delete using the old $params['batch_id'] syntax. */ public function testBatchDeleteOldSyntax() { $batchID = $this->batchCreate(); $params = array( 'batch_id' => $batchID, ); $result = $this->callAPISuccess('batch', 'delete', $params); } /** * Test civicrm_batch_delete using the new $params['id'] syntax */ public function testBatchDeleteCorrectSyntax() { $batchID = $this->batchCreate(); $params = array( 'id' => $batchID, ); $result = $this->callAPIAndDocument('batch', 'delete', $params, __FUNCTION__, __FILE__); } }