_contactId = Contact::createIndividual(); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * Test for Add/Update Pledge. */ public function testAdd() { $params = array( 'contact_id' => $this->_contactId, 'frequency_unit' => 'month', 'original_installment_amount' => 25.00, 'frequency_interval' => 1, 'frequency_day' => 1, 'installments' => 12, 'financial_type_id' => 1, 'create_date' => '20100513000000', 'acknowledge_date' => '20100513000000', 'start_date' => '20100513000000', 'status_id' => 2, 'currency' => 'USD', 'amount' => 300, ); //do test for normal add. $pledge = CRM_Pledge_BAO_Pledge::add($params); foreach ($params as $param => $value) { $this->assertEquals($value, $pledge->$param); } } /** * Retrieve a pledge based on a pledge id = 0 */ public function testRetrieveZeroPledeID() { $defaults = array(); $params = array('pledge_id' => 0); $pledgeId = CRM_Pledge_BAO_Pledge::retrieve($params, $defaults); $this->assertEquals(count($pledgeId), 0, "Pledge Id must be greater than 0"); } /** * Retrieve a payment based on a Null pledge id random string. */ public function testRetrieveStringPledgeID() { $defaults = array(); $params = array('pledge_id' => 'random text'); $pledgeId = CRM_Pledge_BAO_Pledge::retrieve($params, $defaults); $this->assertEquals(count($pledgeId), 0, "Pledge Id must be a string"); } /** * Test that payment retrieve wrks based on known pledge id. */ public function testRetrieveKnownPledgeID() { $params = array( 'contact_id' => $this->_contactId, 'frequency_unit' => 'month', 'frequency_interval' => 1, 'frequency_day' => 1, 'original_installment_amount' => 25.00, 'installments' => 12, 'financial_type_id' => 1, 'create_date' => '20100513000000', 'acknowledge_date' => '20100513000000', 'start_date' => '20100513000000', 'status_id' => 2, 'currency' => 'USD', 'amount' => 300, ); $pledge = CRM_Pledge_BAO_Pledge::add($params); $defaults = array(); $pledgeParams = array('pledge_id' => $pledge->id); $pledgeId = CRM_Pledge_BAO_Pledge::retrieve($pledgeParams, $defaults); $this->assertEquals(count($pledgeId), 1, "Pledge was retrieved"); } }