Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
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 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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Member_StandaloneAddTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testStandaloneMemberAdd() { |
6a488035 | 39 | |
6a488035 TO |
40 | $this->webtestLogin(); |
41 | ||
42 | // create contact | |
43 | $firstName = substr(sha1(rand()), 0, 7); | |
44 | $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name"); | |
45 | $contactName = "Memberson, $firstName"; | |
46 | ||
47 | // add membership type | |
48 | $membershipTypes = $this->webtestAddMembershipType(); | |
49 | ||
50 | // now add membership | |
69369531 | 51 | $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload"); |
6a488035 TO |
52 | |
53 | // select contact | |
54 | $this->webtestFillAutocomplete($firstName); | |
55 | ||
56 | // fill in Membership Organization | |
57 | $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}"); | |
58 | ||
59 | // select membership type | |
60 | $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}"); | |
61 | ||
62 | // fill in Source | |
63 | $this->type("source", "Membership StandaloneAddTest Webtest"); | |
64 | ||
65 | // Let Join Date stay default | |
66 | ||
67 | // fill in Start Date | |
68 | $this->webtestFillDate('start_date'); | |
69 | ||
70 | // Let End Date be auto computed | |
71 | ||
72 | // fill in Status Override? | |
73 | // fill in Record Membership Payment? | |
87fd4550 | 74 | $this->click("send_receipt"); |
16a9c6d8 | 75 | $this->assertTrue($this->isChecked("send_receipt"), 'Send Confirmation and Receipt checkbox should be checked.'); |
6a488035 TO |
76 | $this->click("_qf_Membership_upload"); |
77 | ||
78 | //View Membership | |
79 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
80 | $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']"); | |
81 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
69369531 | 82 | |
6a488035 | 83 | $expected = array( |
69369531 RN |
84 | 'Membership Type' => $membershipTypes['membership_type'], |
85 | 'Status' => 'New', | |
86 | 'Source' => 'Membership StandaloneAddTest Webtest', | |
6a488035 | 87 | ); |
69369531 | 88 | $this->webtestVerifyTabularData($expected); |
6a488035 TO |
89 | } |
90 | ||
00be9182 | 91 | public function testStandaloneGiftMembership() { |
c05d072a | 92 | |
93 | $this->webtestLogin(); | |
94 | ||
95 | // create contact | |
96 | $firstName = substr(sha1(rand()), 0, 7); | |
97 | $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name"); | |
98 | $contactName = "Memberson, $firstName"; | |
99 | ||
100 | $giftMemberfirstName = substr(sha1(rand()), 0, 7); | |
101 | $this->webtestAddContact($giftMemberfirstName, "Memberson", "Memberson{$giftMemberfirstName}@memberson.name"); | |
102 | $giftMembercontactName = "Memberson, $giftMemberfirstName"; | |
103 | ||
104 | // add membership type | |
105 | $membershipTypes = $this->webtestAddMembershipType(); | |
106 | ||
107 | // now add membership | |
108 | $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload"); | |
109 | ||
110 | // select contact | |
111 | $this->webtestFillAutocomplete($firstName); | |
112 | ||
113 | // fill in Membership Organization | |
114 | $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}"); | |
115 | ||
116 | // select membership type | |
117 | $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}"); | |
118 | ||
119 | // fill in Source | |
120 | $this->type("source", "Membership StandaloneAddTest Webtest"); | |
121 | ||
122 | // fill in Start Date | |
123 | $this->webtestFillDate('start_date'); | |
124 | ||
125 | // add softcredit details | |
126 | $totalAmount = 100; | |
127 | $financialType = 'Donation'; | |
6c6e6187 | 128 | $this->clickLink('is_different_contribution_contact', 'total_amount', FALSE); |
c05d072a | 129 | |
130 | $this->select('soft_credit_type_id', 'Gift'); | |
131 | $this->select2('soft_credit_contact_id', $giftMembercontactName); | |
6c6e6187 | 132 | $this->select('financial_type_id', 'Donation'); |
c05d072a | 133 | $this->type('total_amount', $totalAmount); |
134 | $this->select('payment_instrument_id', 'Check'); | |
135 | $this->select('contribution_status_id', 'Completed'); | |
136 | ||
cd223eef | 137 | $this->clickLink("_qf_Membership_upload"); |
c05d072a | 138 | |
139 | //View Membership | |
80ba1424 | 140 | $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr[1]/td[9]/span/a[text()='View']"); |
cd223eef | 141 | $this->click("xpath=//table[@class='display dataTable no-footer']/tbody/tr[1]/td[9]/span/a[text()='View']"); |
c05d072a | 142 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
143 | ||
144 | // verify soft credit data | |
145 | $expected = array( | |
92fcb95f | 146 | '1' => $giftMemberfirstName . ' Memberson', |
c05d072a | 147 | '2' => $totalAmount, |
148 | '3' => 'Gift', | |
149 | '4' => 'Donation', | |
150 | '6' => 'Completed', | |
151 | ); | |
152 | ||
22e263ad | 153 | foreach ($expected as $key => $value) { |
c05d072a | 154 | $this->verifyText("xpath=//div[@class='crm-accordion-wrapper']//table/tbody//tr/td[$key]", $value); |
155 | } | |
156 | ||
157 | } | |
158 | ||
00be9182 | 159 | public function testStandaloneMemberOverrideAdd() { |
6a488035 | 160 | |
6a488035 TO |
161 | $this->webtestLogin(); |
162 | ||
163 | // add contact | |
164 | $firstName = substr(sha1(rand()), 0, 7); | |
165 | $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name"); | |
166 | $contactName = "Memberson, $firstName"; | |
167 | ||
168 | // add membership type | |
169 | $membershipTypes = $this->webtestAddMembershipType(); | |
170 | ||
171 | // add membership | |
69369531 | 172 | $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload"); |
6a488035 TO |
173 | |
174 | // select contact | |
175 | $this->webtestFillAutocomplete($firstName); | |
176 | ||
177 | // fill in Membership Organization | |
178 | $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}"); | |
179 | ||
180 | // select membership type | |
181 | $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}"); | |
182 | ||
183 | // fill in Source | |
184 | $this->type("source", "Membership StandaloneAddTest Webtest"); | |
185 | ||
186 | // Let Join Date stay default | |
187 | ||
188 | // fill in Start Date | |
189 | $this->webtestFillDate('start_date'); | |
190 | ||
191 | // Let End Date be auto computed | |
192 | ||
193 | // fill in Status Override? | |
194 | $this->click("is_override", "value=1"); | |
195 | $this->waitForElementPresent("status_id"); | |
196 | $this->select("status_id", "value=3"); | |
197 | ||
198 | // fill in Record Membership Payment? | |
199 | $this->click("record_contribution", "value=1"); | |
200 | $this->waitForElementPresent("contribution_status_id"); | |
6c6e6187 | 201 | // let financial type be default |
6a488035 TO |
202 | |
203 | // let the amount be default | |
204 | ||
205 | // select payment instrument type = Check and enter chk number | |
206 | $this->select("payment_instrument_id", "value=4"); | |
207 | $this->waitForElementPresent("check_number"); | |
208 | $this->type("check_number", "check #12345"); | |
209 | $this->type("trxn_id", "P5476785" . rand(100, 10000)); | |
210 | ||
211 | // fill the payment status be default | |
212 | $this->select("contribution_status_id", "value=2"); | |
213 | ||
214 | //---- | |
215 | ||
216 | // Clicking save. | |
217 | $this->click("_qf_Membership_upload"); | |
218 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
219 | ||
220 | // page was loaded | |
221 | $this->waitForTextPresent("Membership StandaloneAddTest Webtest"); | |
222 | ||
223 | // verify if Membership is created | |
224 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
225 | ||
226 | //click through to the Membership view screen | |
227 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
228 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
229 | ||
230 | $expected = array( | |
69369531 RN |
231 | 'Membership Type' => $membershipTypes['membership_type'], |
232 | 'Status' => 'Grace', | |
233 | 'Source' => 'Membership StandaloneAddTest Webtest', | |
6a488035 | 234 | ); |
69369531 | 235 | $this->webtestVerifyTabularData($expected); |
6a488035 | 236 | } |
6a488035 | 237 | |
00be9182 | 238 | public function testAjaxCustomGroupLoad() { |
c4e6d4e8 PJ |
239 | $this->webtestLogin(); |
240 | $triggerElement = array('name' => 'membership_type_id_1', 'type' => 'select'); | |
241 | $customSets = array( | |
242 | array('entity' => 'Membership', 'subEntity' => 'General', 'triggerElement' => $triggerElement), | |
21dfd5f5 | 243 | array('entity' => 'Membership', 'subEntity' => 'Student', 'triggerElement' => $triggerElement), |
c4e6d4e8 PJ |
244 | ); |
245 | ||
246 | $pageUrl = array('url' => 'member/add', 'args' => 'reset=1&action=add&context=standalone'); | |
5b8ddc60 PJ |
247 | |
248 | //case where we should fire certain | |
249 | //ui actions which helps triggering possible | |
250 | $test = $this; | |
251 | $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl, | |
92915c55 | 252 | function () use ($test) { |
e70a7fc0 | 253 | $test->select('membership_type_id_0', 'value=1'); |
5b8ddc60 PJ |
254 | } |
255 | ); | |
c4e6d4e8 | 256 | } |
96025800 | 257 | |
232624b1 | 258 | } |