Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 | 27 | |
6a488035 TO |
28 | require_once 'CiviTest/Contact.php'; |
29 | require_once 'CiviTest/ContributionPage.php'; | |
30 | require_once 'CiviTest/Custom.php'; | |
31 | require_once 'CiviTest/PaypalPro.php'; | |
4cbe18b8 EM |
32 | |
33 | /** | |
34 | * Class CRM_Contribute_BAO_ContributionPageTest | |
acb109b7 | 35 | * @group headless |
4cbe18b8 | 36 | */ |
6a488035 | 37 | class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { |
6a488035 | 38 | |
00be9182 | 39 | public function setUp() { |
6a488035 | 40 | parent::setUp(); |
e6ff1593 | 41 | $this->_financialTypeID = 1; |
6a488035 TO |
42 | } |
43 | ||
00be9182 | 44 | public function tearDown() { |
6a488035 TO |
45 | } |
46 | ||
47 | /** | |
100fef9d | 48 | * Create() method (create Contribution Page) |
6a488035 | 49 | */ |
00be9182 | 50 | public function testCreate() { |
6a488035 TO |
51 | |
52 | $params = array( | |
53 | 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e', | |
54 | 'title' => 'Test Contribution Page', | |
e6ff1593 | 55 | 'financial_type_id' => $this->_financialTypeID, |
6a488035 TO |
56 | 'intro_text' => '', |
57 | 'footer_text' => 'Thanks', | |
58 | 'is_for_organization' => 0, | |
59 | 'for_organization' => ' I am contributing on behalf of an organization', | |
60 | 'goal_amount' => '400', | |
61 | 'is_active' => 1, | |
62 | 'honor_block_title' => '', | |
63 | 'honor_block_text' => '', | |
64 | 'start_date' => '20091022105900', | |
65 | 'start_date_time' => '10:59AM', | |
66 | 'end_date' => '19700101000000', | |
67 | 'end_date_time' => '', | |
68 | 'is_credit_card_only' => '', | |
69 | ); | |
70 | ||
6a488035 TO |
71 | $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params); |
72 | ||
73 | $this->assertNotNull($contributionpage->id); | |
74 | $this->assertType('int', $contributionpage->id); | |
75 | ContributionPage::delete($contributionpage->id); | |
76 | } | |
77 | ||
78 | /** | |
79 | * test setIsActive() method | |
80 | */ | |
00be9182 | 81 | public function testsetIsActive() { |
6a488035 TO |
82 | |
83 | $params = array( | |
84 | 'title' => 'Test Contribution Page', | |
e6ff1593 | 85 | 'financial_type_id' => $this->_financialTypeID, |
6a488035 TO |
86 | 'is_active' => 1, |
87 | ); | |
88 | ||
89 | $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params); | |
92915c55 TO |
90 | $id = $contributionpage->id; |
91 | $is_active = 1; | |
92 | $pageActive = CRM_Contribute_BAO_ContributionPage::setIsActive($id, $is_active); | |
6c6e6187 | 93 | $this->assertEquals($pageActive, TRUE, 'Verify financial types record deletion.'); |
6a488035 TO |
94 | ContributionPage::delete($contributionpage->id); |
95 | } | |
96 | ||
97 | /** | |
100fef9d | 98 | * Test setValues() method |
6a488035 | 99 | */ |
00be9182 | 100 | public function testSetValues() { |
6a488035 TO |
101 | |
102 | $params = array( | |
103 | 'title' => 'Test Contribution Page', | |
e6ff1593 | 104 | 'financial_type_id' => $this->_financialTypeID, |
6a488035 TO |
105 | 'is_active' => 1, |
106 | ); | |
107 | ||
108 | $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params); | |
109 | ||
92915c55 TO |
110 | $id = $contributionpage->id; |
111 | $values = array(); | |
6a488035 TO |
112 | $setValues = CRM_Contribute_BAO_ContributionPage::setValues($id, $values); |
113 | ||
114 | $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.'); | |
e6ff1593 | 115 | $this->assertEquals($this->_financialTypeID, $values['financial_type_id'], 'Verify financial types id.'); |
6a488035 TO |
116 | $this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.'); |
117 | ContributionPage::delete($contributionpage->id); | |
118 | } | |
119 | ||
120 | /** | |
100fef9d | 121 | * Test copy() method |
6a488035 | 122 | */ |
00be9182 | 123 | public function testcopy() { |
6a488035 TO |
124 | $params = array( |
125 | 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e', | |
126 | 'title' => 'Test Contribution Page', | |
e6ff1593 | 127 | 'financial_type_id' => $this->_financialTypeID, |
6a488035 TO |
128 | 'intro_text' => '', |
129 | 'footer_text' => 'Thanks', | |
130 | 'is_for_organization' => 0, | |
131 | 'for_organization' => ' I am contributing on behalf of an organization', | |
132 | 'goal_amount' => '400', | |
133 | 'is_active' => 1, | |
134 | 'honor_block_title' => '', | |
135 | 'honor_block_text' => '', | |
136 | 'start_date' => '20091022105900', | |
137 | 'start_date_time' => '10:59AM', | |
138 | 'end_date' => '19700101000000', | |
139 | 'end_date_time' => '', | |
140 | 'is_credit_card_only' => '', | |
141 | ); | |
142 | ||
6a488035 TO |
143 | $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params); |
144 | $copycontributionpage = CRM_Contribute_BAO_ContributionPage::copy($contributionpage->id); | |
e6ff1593 | 145 | $this->assertEquals($copycontributionpage->financial_type_id, $this->_financialTypeID, 'Check for Financial type id.'); |
6a488035 TO |
146 | $this->assertEquals($copycontributionpage->goal_amount, 400, 'Check for goal amount.'); |
147 | ContributionPage::delete($contributionpage->id); | |
148 | ContributionPage::delete($copycontributionpage->id); | |
149 | } | |
150 | ||
6a488035 | 151 | } |