contactIds[] = $this->individualCreate(); $this->params = array( 'title' => "Test Contribution Page", 'financial_type_id' => 1, 'currency' => 'NZD', 'goal_amount' => $this->testAmount, ); } function tearDown() { foreach ($this->contactIds as $id) { $this->callAPISuccess('contact', 'delete', array('id' => $id)); }if(!empty($this->id)){ $this->callAPISuccess('contribution_page', 'delete', array('id' => $this->id)); } } public function testCreateContributionPage() { $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params, __FUNCTION__, __FILE__); $this->assertEquals(1, $result['count']); $this->assertNotNull($result['values'][$result['id']]['id']); $this->getAndCheck($this->params, $result['id'], $this->_entity); } public function testGetBasicContributionPage() { $createResult = $this->callAPISuccess($this->_entity, 'create', $this->params); $this->id = $createResult['id']; $getParams = array( 'currency' => 'NZD', 'financial_type_id' => 1, ); $getResult = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__); $this->assertEquals(1, $getResult['count']); } public function testGetContributionPageByAmount() { $createResult = $this->callAPISuccess($this->_entity, 'create', $this->params); $this->id = $createResult['id']; $getParams = array( 'amount' => ''. $this->testAmount, // 3456 'currency' => 'NZD', 'financial_type_id' => 1, ); $getResult = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__); $this->assertEquals(1, $getResult['count']); } public function testDeleteContributionPage() { $createResult = $this->callAPISuccess($this->_entity, 'create', $this->params); $deleteParams = array('id' => $createResult['id']); $deleteResult = $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__); $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array()); $this->assertEquals(0, $checkDeleted['count']); } public function testGetFieldsContributionPage() { $result = $this->callAPISuccess($this->_entity, 'getfields', array('action' => 'create')); $this->assertEquals(12, $result['values']['start_date']['type']); } public static function setUpBeforeClass() { // put stuff here that should happen before all tests in this unit } public static function tearDownAfterClass(){ $tablesToTruncate = array( 'civicrm_contact', 'civicrm_financial_type', 'civicrm_contribution', 'civicrm_contribution_page', ); $unitTest = new CiviUnitTestCase(); $unitTest->quickCleanup($tablesToTruncate); } }