3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Test class for CRM_Pledge_BAO_Pledge BAO
34 class CRM_Pledge_BAO_PledgeTest
extends CiviUnitTestCase
{
37 * Sets up the fixture, for example, opens a network connection.
38 * This method is called before a test is executed.
40 protected function setUp() {
42 $this->_contactId
= Contact
::createIndividual();
46 * Tears down the fixture, for example, closes a network connection.
47 * This method is called after a test is executed.
49 protected function tearDown() {
53 * Test for Add/Update Pledge.
55 public function testAdd() {
57 'contact_id' => $this->_contactId
,
58 'frequency_unit' => 'month',
59 'original_installment_amount' => 25.00,
60 'frequency_interval' => 1,
63 'financial_type_id' => 1,
64 'create_date' => '20100513000000',
65 'acknowledge_date' => '20100513000000',
66 'start_date' => '20100513000000',
72 //do test for normal add.
73 $pledge = CRM_Pledge_BAO_Pledge
::add($params);
75 foreach ($params as $param => $value) {
76 $this->assertEquals($value, $pledge->$param);
81 * Retrieve a pledge based on a pledge id = 0
83 public function testRetrieveZeroPledeID() {
85 $params = array('pledge_id' => 0);
86 $pledgeId = CRM_Pledge_BAO_Pledge
::retrieve($params, $defaults);
88 $this->assertEquals(count($pledgeId), 0, "Pledge Id must be greater than 0");
92 * Retrieve a payment based on a Null pledge id random string.
94 public function testRetrieveStringPledgeID() {
96 $params = array('pledge_id' => 'random text');
97 $pledgeId = CRM_Pledge_BAO_Pledge
::retrieve($params, $defaults);
99 $this->assertEquals(count($pledgeId), 0, "Pledge Id must be a string");
103 * Test that payment retrieve wrks based on known pledge id.
105 public function testRetrieveKnownPledgeID() {
107 'contact_id' => $this->_contactId
,
108 'frequency_unit' => 'month',
109 'frequency_interval' => 1,
110 'frequency_day' => 1,
111 'original_installment_amount' => 25.00,
112 'installments' => 12,
113 'financial_type_id' => 1,
114 'create_date' => '20100513000000',
115 'acknowledge_date' => '20100513000000',
116 'start_date' => '20100513000000',
122 $pledge = CRM_Pledge_BAO_Pledge
::add($params);
125 $pledgeParams = array('pledge_id' => $pledge->id
);
127 $pledgeId = CRM_Pledge_BAO_Pledge
::retrieve($pledgeParams, $defaults);
129 $this->assertEquals(count($pledgeId), 1, "Pledge was retrieved");