Fixed some contribution pages
[civicrm-core.git] / tests / phpunit / WebTest / Member / StandaloneAddTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 */
26
27
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testStandaloneMemberAdd() {
36
37 $this->webtestLogin();
38
39 // create contact
40 $firstName = substr(sha1(rand()), 0, 7);
41 $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
42 $contactName = "Memberson, $firstName";
43
44 // add membership type
45 $membershipTypes = $this->webtestAddMembershipType();
46
47 // now add membership
48 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
49
50 // select contact
51 $this->webtestFillAutocomplete($firstName);
52
53 // fill in Membership Organization
54 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
55
56 // select membership type
57 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
58
59 // fill in Source
60 $this->type("source", "Membership StandaloneAddTest Webtest");
61
62 // Let Join Date stay default
63
64 // fill in Start Date
65 $this->webtestFillDate('start_date');
66
67 // Let End Date be auto computed
68
69 // fill in Status Override?
70 // fill in Record Membership Payment?
71
72 $this->click("_qf_Membership_upload");
73
74 //View Membership
75 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
76 $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
77 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
78
79 $expected = array(
80 'Membership Type' => $membershipTypes['membership_type'],
81 'Status' => 'New',
82 'Source' => 'Membership StandaloneAddTest Webtest',
83 );
84 $this->webtestVerifyTabularData($expected);
85 }
86
87 function testStandaloneMemberOverrideAdd() {
88
89 $this->webtestLogin();
90
91 // add contact
92 $firstName = substr(sha1(rand()), 0, 7);
93 $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
94 $contactName = "Memberson, $firstName";
95
96 // add membership type
97 $membershipTypes = $this->webtestAddMembershipType();
98
99 // add membership
100 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
101
102 // select contact
103 $this->webtestFillAutocomplete($firstName);
104
105 // fill in Membership Organization
106 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
107
108 // select membership type
109 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
110
111 // fill in Source
112 $this->type("source", "Membership StandaloneAddTest Webtest");
113
114 // Let Join Date stay default
115
116 // fill in Start Date
117 $this->webtestFillDate('start_date');
118
119 // Let End Date be auto computed
120
121 // fill in Status Override?
122 $this->click("is_override", "value=1");
123 $this->waitForElementPresent("status_id");
124 $this->select("status_id", "value=3");
125
126 // fill in Record Membership Payment?
127 $this->click("record_contribution", "value=1");
128 $this->waitForElementPresent("contribution_status_id");
129 // let financial type be default
130
131 // let the amount be default
132
133 // select payment instrument type = Check and enter chk number
134 $this->select("payment_instrument_id", "value=4");
135 $this->waitForElementPresent("check_number");
136 $this->type("check_number", "check #12345");
137 $this->type("trxn_id", "P5476785" . rand(100, 10000));
138
139 // fill the payment status be default
140 $this->select("contribution_status_id", "value=2");
141
142 //----
143
144 // Clicking save.
145 $this->click("_qf_Membership_upload");
146 $this->waitForPageToLoad($this->getTimeoutMsec());
147
148 // page was loaded
149 $this->waitForTextPresent("Membership StandaloneAddTest Webtest");
150
151 // verify if Membership is created
152 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
153
154 //click through to the Membership view screen
155 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
156 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
157
158 $expected = array(
159 'Membership Type' => $membershipTypes['membership_type'],
160 'Status' => 'Grace',
161 'Source' => 'Membership StandaloneAddTest Webtest',
162 );
163 $this->webtestVerifyTabularData($expected);
164 }
165 }
166
167