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