Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
15a4309a | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
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_InheritedMembershipTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { |
33 | protected function setUp() { | |
34 | parent::setUp(); | |
35 | } | |
36 | ||
00be9182 | 37 | public function testInheritedMembership() { |
d3f2fd13 | 38 | //$this->markTestSkipped('Skipping for now as it works fine locally.'); |
6a488035 TO |
39 | // Log in using webtestLogin() method |
40 | $this->webtestLogin(); | |
41 | ||
9d15e987 | 42 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
6a488035 TO |
43 | |
44 | $title = substr(sha1(rand()), 0, 7); | |
45 | $this->type('organization_name', "Organization $title"); | |
46 | $this->type('email_1_email', "$title@org.com"); | |
47 | $this->click('_qf_Contact_upload_view'); | |
48 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 49 | $this->waitForText('crm-notification-container', "Organization {$title} has been created."); |
6a488035 | 50 | |
9d15e987 | 51 | $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); |
6a488035 TO |
52 | |
53 | $this->click('link=Add Membership Type'); | |
54 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
55 | ||
56 | $this->type('name', "Membership Type $title"); | |
57 | ||
fc2fa8f8 | 58 | $this->select2('member_of_contact_id', $title); |
6a488035 TO |
59 | |
60 | $this->type('minimum_fee', '100'); | |
481a74f4 | 61 | $this->select('financial_type_id', 'value=2'); |
6a488035 TO |
62 | $this->type('duration_interval', 1); |
63 | $this->select('duration_unit', 'label=year'); | |
64 | ||
fc2fa8f8 | 65 | $this->select('period_type', 'value=rolling'); |
6a488035 | 66 | |
f64f0f3c | 67 | $this->select2('relationship_type_id', 'Employer of', TRUE); |
6a488035 TO |
68 | $this->type('max_related', '5'); |
69 | ||
70 | $this->click('_qf_MembershipType_upload-bottom'); | |
71 | $this->waitForElementPresent('link=Add Membership Type'); | |
6c5f7368 | 72 | $this->waitForText('crm-notification-container', "Membership Type $title"); |
6a488035 | 73 | |
9d15e987 | 74 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
6a488035 TO |
75 | |
76 | // creating another Orgnization | |
77 | $title1 = substr(sha1(rand()), 0, 7); | |
78 | $this->type('organization_name', "Organization $title1"); | |
79 | $this->type('email_1_email', "$title1@org.com"); | |
80 | $this->click('_qf_Contact_upload_view'); | |
81 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
82 | ||
83 | // click through to the membership view screen | |
84 | $this->click('css=li#tab_member a'); | |
85 | ||
86 | $this->waitForElementPresent('link=Add Membership'); | |
87 | $this->click('link=Add Membership'); | |
88 | ||
89 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
90 | ||
91 | // fill in Membership Organization and Type | |
92 | $this->select('membership_type_id[0]', "label=Organization $title"); | |
93 | $this->select('membership_type_id[1]', "label=Membership Type $title"); | |
94 | ||
95 | $sourceText = 'Membership ContactAddTest with Fixed Membership Type'; | |
96 | // fill in Source | |
97 | $this->type('source', $sourceText); | |
98 | ||
99 | // Clicking save. | |
100 | $this->click('_qf_Membership_upload'); | |
fc2fa8f8 | 101 | $this->waitForElementPresent('link=Add Membership'); |
6a488035 TO |
102 | |
103 | // page was loaded | |
104 | $this->waitForTextPresent($sourceText); | |
105 | ||
106 | // Is status message correct? | |
6c5f7368 | 107 | $this->waitForText('crm-notification-container', "Membership Type $title"); |
6a488035 TO |
108 | |
109 | // click through to the membership view screen | |
110 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
111 | $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); | |
112 | ||
92915c55 TO |
113 | $joinDate = date('Y-m-d'); |
114 | $startDate = date('Y-m-d'); | |
115 | $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y') + 1)); | |
6a488035 | 116 | foreach (array( |
92915c55 TO |
117 | 'joinDate', |
118 | 'startDate', | |
408b79bf | 119 | 'endDate', |
92915c55 | 120 | ) as $date) { |
d3f2fd13 | 121 | $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('dateformatFull')); |
6a488035 | 122 | } |
9d15e987 | 123 | |
6a488035 TO |
124 | $this->webtestVerifyTabularData( |
125 | array( | |
126 | 'Membership Type' => "Membership Type $title", | |
127 | 'Status' => 'New', | |
128 | 'Source' => $sourceText, | |
129 | 'Member Since' => $joinDate, | |
130 | 'Start date' => $startDate, | |
131 | 'End date' => $endDate, | |
21dfd5f5 | 132 | 'Max related' => "5", |
6a488035 TO |
133 | ) |
134 | ); | |
135 | ||
136 | // Adding contact | |
137 | // We're using Quick Add block on the main page for this. | |
138 | $firstName = substr(sha1(rand()), 0, 7); | |
139 | $this->webtestAddContact($firstName, 'Anderson', "$firstName@anderson.name"); | |
140 | ||
141 | // visit relationship tab | |
142 | $this->click('css=li#tab_rel a'); | |
143 | $this->waitForElementPresent('css=div.action-link'); | |
fc2fa8f8 | 144 | $this->click("//div[@class='action-link']/a/span"); |
145 | $this->waitForElementPresent('_qf_Relationship_cancel-bottom'); | |
6a488035 TO |
146 | $this->click('relationship_type_id'); |
147 | $this->select('relationship_type_id', 'label=Employee of'); | |
148 | ||
fc2fa8f8 | 149 | $this->select2('related_contact_id', $title1, TRUE); |
6a488035 TO |
150 | |
151 | $description = 'Well here is some description !!!!'; | |
152 | $this->type('description', $description); | |
153 | ||
154 | //save the relationship | |
fc2fa8f8 | 155 | $this->click('_qf_Relationship_upload-bottom'); |
cebea087 | 156 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); |
6a488035 | 157 | //check the status message |
fc2fa8f8 | 158 | $this->waitForText('crm-notification-container', 'Relationship created.'); |
6a488035 | 159 | |
cebea087 | 160 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='View']"); |
6a488035 TO |
161 | |
162 | // click through to the membership view screen | |
163 | $this->click('css=li#tab_member a'); | |
164 | $this->waitForElementPresent('css=div#memberships'); | |
165 | ||
166 | // click through to the membership view screen | |
167 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
168 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
169 | ||
170 | $this->webtestVerifyTabularData( | |
171 | array( | |
172 | 'Membership Type' => "Membership Type $title", | |
173 | 'Status' => 'New', | |
174 | 'Source' => $sourceText, | |
175 | 'Member Since' => $joinDate, | |
176 | 'Start date' => $startDate, | |
177 | 'End date' => $endDate, | |
178 | ) | |
179 | ); | |
180 | $this->click("_qf_MembershipView_cancel-bottom"); | |
181 | $this->waitForElementPresent('css=div#memberships'); | |
182 | ||
183 | //1. change relationship status on form | |
184 | $this->click('css=li#tab_rel a'); | |
185 | $this->waitForElementPresent('css=div.action-link'); | |
186 | ||
187 | $this->click("//li[@id='tab_rel']/a"); | |
cebea087 | 188 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); |
189 | $id = explode('&id=', $this->getAttribute("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a@href")); | |
fc2fa8f8 | 190 | $id = explode('&', $id[0]); |
191 | $id = explode('=', $id[2]); | |
192 | $id = $id[1]; | |
cebea087 | 193 | $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); |
6a488035 TO |
194 | |
195 | $this->waitForElementPresent('is_active'); | |
196 | //disable relationship | |
197 | if ($this->isChecked('is_active')) { | |
198 | $this->click('is_active'); | |
199 | } | |
200 | $this->click('_qf_Relationship_upload'); | |
cebea087 | 201 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); |
6a488035 | 202 | //check the status message |
6c5f7368 | 203 | $this->waitForText('crm-notification-container', 'Relationship record has been updated'); |
6a488035 TO |
204 | |
205 | // click through to the membership view screen | |
206 | $this->click('css=li#tab_member a'); | |
207 | ||
208 | //verify inherited membership has been removed | |
fc2fa8f8 | 209 | $this->openCiviPage("contact/view", "reset=1&cid=$id&selectedChild=member", "xpath=//div[@class='view-content']/div[3]"); |
a63c43ee | 210 | $this->waitForTextPresent("No memberships have been recorded for this contact."); |
6a488035 TO |
211 | |
212 | // visit relationship tab and re-enable the relationship | |
213 | $this->click('css=li#tab_rel a'); | |
214 | $this->waitForElementPresent('css=div.action-link'); | |
215 | $this->click("//li[@id='tab_rel']/a"); | |
9d15e987 | 216 | |
cebea087 | 217 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); |
218 | $this->click("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); | |
6a488035 TO |
219 | $this->waitForElementPresent('is_active'); |
220 | if (!$this->isChecked('is_active')) { | |
221 | $this->click('is_active'); | |
222 | } | |
223 | $this->click('_qf_Relationship_upload'); | |
cebea087 | 224 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); |
6a488035 | 225 | //check the status message |
6c5f7368 | 226 | $this->waitForText('crm-notification-container', 'Relationship record has been updated.'); |
6a488035 TO |
227 | |
228 | //check for memberships | |
229 | $this->click('css=li#tab_member a'); | |
230 | $this->waitForElementPresent('css=div#memberships'); | |
231 | ||
232 | //2 . visit relationship tab and disable the relationship (by links) | |
233 | //disable relationship | |
234 | $this->click('css=li#tab_rel a'); | |
235 | $this->waitForElementPresent('css=div.action-link'); | |
cebea087 | 236 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']"); |
237 | $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']"); | |
a63c43ee | 238 | $this->waitForTextPresent('Are you sure you want to disable this relationship?'); |
cebea087 | 239 | $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Yes']"); |
efb29358 CW |
240 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
241 | // Sleep should never be used for wait for anything to load from the server | |
242 | // Justification for this instance: FIXME | |
6a488035 TO |
243 | sleep(10); |
244 | ||
245 | //verify inherited membership has been removed | |
fc2fa8f8 | 246 | $this->openCiviPage("contact/view", "reset=1&cid={$id}&selectedChild=member", "xpath=//div[@class='view-content']/div[3]"); |
a63c43ee | 247 | $this->waitForTextPresent("No memberships have been recorded for this contact."); |
6a488035 TO |
248 | |
249 | //enable relationship | |
250 | $this->click('css=li#tab_rel a'); | |
251 | $this->waitForElementPresent('css=div.action-link'); | |
252 | ||
a63c43ee | 253 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody/tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Enable']"); |
254 | $this->click("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody/tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Enable']"); | |
6a488035 TO |
255 | |
256 | //verify membership | |
257 | $this->click('css=li#tab_member a'); | |
a63c43ee | 258 | $this->waitForTextPresent("No memberships have been recorded for this contact."); |
6a488035 | 259 | } |
385f7a49 | 260 | |
d424ffde | 261 | /** |
385f7a49 | 262 | * Webtest for CRM-10146 |
385f7a49 | 263 | */ |
00be9182 | 264 | public function testInheritedMembershipActivity() { |
385f7a49 | 265 | // Log in using webtestLogin() method |
266 | $this->webtestLogin(); | |
267 | ||
268 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); | |
269 | ||
270 | $title = substr(sha1(rand()), 0, 7); | |
271 | $this->type('organization_name', "Organization $title"); | |
272 | $this->type('email_1_email', "$title@org.com"); | |
273 | $this->clickLink('_qf_Contact_upload_view'); | |
274 | $this->waitForText('crm-notification-container', "Organization {$title} has been created."); | |
275 | ||
276 | $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); | |
277 | ||
278 | $this->click('link=Add Membership Type'); | |
279 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
280 | ||
281 | $this->type('name', "Membership Type $title"); | |
282 | ||
fc2fa8f8 | 283 | $this->select2('member_of_contact_id', $title); |
385f7a49 | 284 | |
285 | $this->type('minimum_fee', '100'); | |
286 | $this->select('financial_type_id', 'label=Member Dues'); | |
287 | $this->type('duration_interval', 1); | |
288 | $this->select('duration_unit', 'label=year'); | |
289 | ||
fc2fa8f8 | 290 | $this->select('period_type', 'value=rolling'); |
385f7a49 | 291 | |
318b7c06 | 292 | $this->select2('relationship_type_id', 'Employer of', TRUE); |
385f7a49 | 293 | |
294 | $this->type('max_related', '5'); | |
295 | ||
296 | $this->click('_qf_MembershipType_upload-bottom'); | |
297 | $this->waitForElementPresent('link=Add Membership Type'); | |
298 | $this->waitForText('crm-notification-container', "Membership Type $title"); | |
299 | ||
c206647d | 300 | // creating another Organization |
385f7a49 | 301 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
302 | $org1 = substr(sha1(rand()), 0, 7); | |
303 | $this->type('organization_name', "Organization $org1"); | |
304 | $this->type('email_1_email', "$org1@org.com"); | |
305 | $this->clickLink('_qf_Contact_upload_view'); | |
306 | ||
307 | // click through to the membership view screen | |
308 | $this->click('css=li#tab_member a'); | |
309 | ||
310 | $this->waitForElementPresent('link=Add Membership'); | |
311 | $this->click('link=Add Membership'); | |
312 | ||
313 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
314 | ||
315 | // fill in Membership Organization and Type | |
316 | $this->select('membership_type_id[0]', "label=Organization $title"); | |
317 | $this->select('membership_type_id[1]', "label=Membership Type $title"); | |
318 | ||
319 | $sourceText = 'Membership ContactAddTest with Rolling Membership Type'; | |
320 | // fill in Source | |
321 | $this->type('source', $sourceText); | |
322 | ||
323 | // Clicking save. | |
fc2fa8f8 | 324 | $this->click('_qf_Membership_upload'); |
385f7a49 | 325 | |
326 | // page was loaded | |
327 | $this->waitForTextPresent($sourceText); | |
328 | ||
329 | // Is status message correct? | |
330 | $this->waitForText('crm-notification-container', "Membership Type $title"); | |
331 | ||
332 | // Adding contact | |
333 | $this->openCiviPage('contact/add', 'reset=1&ct=Individual', '_qf_Contact_cancel-bottom'); | |
334 | $firstName = substr(sha1(rand()), 0, 7); | |
335 | $lastName = 'Anderson'; | |
336 | $email = "$firstName@anderson.name"; | |
337 | $this->type("first_name", $firstName); | |
338 | $this->type("last_name", $lastName); | |
339 | ||
340 | // Set Current Employer | |
fc2fa8f8 | 341 | $this->select2('employer_id', $org1); |
342 | $this->waitForText('s2id_employer_id', $org1); | |
385f7a49 | 343 | |
344 | $this->type("email_1_email", $email); | |
345 | $this->clickLink("_qf_Contact_upload_view-bottom"); | |
346 | $cid = $this->urlArg('cid'); | |
347 | ||
348 | // click through to the membership view screen | |
349 | $this->click('css=li#tab_member a'); | |
350 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
351 | ||
352 | // check number of membership for contact | |
353 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em")); | |
354 | ||
cebea087 | 355 | $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href")); |
356 | $expectedMembershipId = $url['queryString']['id']; | |
385f7a49 | 357 | |
358 | // click through to the activity view screen | |
359 | $this->click('css=li#tab_activity a'); | |
6e677443 | 360 | $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody/tr/td[8]/span/a"); |
385f7a49 | 361 | |
362 | // check number of activity for contact | |
363 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); | |
364 | ||
6e677443 | 365 | $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody/tr/td[8]/span/a@href")); |
cebea087 | 366 | $expectedMembershipActivityId = $url['queryString']['id']; |
385f7a49 | 367 | |
368 | // verify membership id with membership activity id | |
369 | $this->assertEquals($expectedMembershipId, $expectedMembershipActivityId); | |
370 | ||
371 | // click through to the relationship view screen | |
372 | $this->click('css=li#tab_rel a'); | |
cebea087 | 373 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
374 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org1']")); | |
385f7a49 | 375 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
376 | ||
377 | // Edit Contact but do not change any field | |
27c7ef42 RN |
378 | $this->waitForElementPresent("xpath=//ul[@id='actions']/li[2]/a/span"); |
379 | $this->clickLink("xpath=//ul[@id='actions']/li[2]/a/span"); | |
385f7a49 | 380 | $this->waitForElementPresent('_qf_Contact_cancel-bottom'); |
381 | $this->clickLink("_qf_Contact_upload_view-top"); | |
382 | ||
383 | // click through to the membership view screen after edit | |
384 | $this->click('css=li#tab_member a'); | |
385 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
3350f8b4 | 386 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em")); |
cebea087 | 387 | |
388 | $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href")); | |
389 | $actualMembershipId1 = $url['queryString']['id']; | |
385f7a49 | 390 | |
391 | // click through to the activity view screen after edit | |
392 | $this->click('css=li#tab_activity a'); | |
6e677443 | 393 | $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody/tr/td[8]/span/a"); |
3350f8b4 | 394 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
895231b4 | 395 | $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody/tr/td[8]/span/a@href")); |
cebea087 | 396 | $actualMembershipActivityId1 = $url['queryString']['id']; |
385f7a49 | 397 | |
398 | // verify membership id and membership activity id with previous one | |
3350f8b4 | 399 | // FIXME: These 2 lines are currently failing because the inherited membership and signup activity or being recreated when contact is edited/saved. dgg |
385f7a49 | 400 | $this->assertEquals($expectedMembershipId, $actualMembershipId1); |
ad8d7765 | 401 | $this->assertEquals($expectedMembershipActivityId, $actualMembershipActivityId1); |
385f7a49 | 402 | |
403 | // click through to the relationship view screen after edit | |
404 | $this->click('css=li#tab_rel a'); | |
cebea087 | 405 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
406 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org1']")); | |
385f7a49 | 407 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
408 | ||
409 | // change the current employer of the contact | |
410 | // creating another membership type | |
411 | $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); | |
412 | ||
413 | $this->click('link=Add Membership Type'); | |
414 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
415 | ||
416 | $this->type('name', "Membership Type Another $title"); | |
417 | ||
cebea087 | 418 | $this->select2('member_of_contact_id', $title); |
385f7a49 | 419 | |
420 | $this->type('minimum_fee', '100'); | |
421 | $this->select('financial_type_id', 'label=Member Dues'); | |
422 | $this->type('duration_interval', 1); | |
423 | $this->select('duration_unit', 'label=year'); | |
424 | ||
cebea087 | 425 | $this->select('period_type', 'value=rolling'); |
385f7a49 | 426 | |
80a9d035 | 427 | $this->select2('relationship_type_id', 'Employer of', TRUE); |
385f7a49 | 428 | $this->type('max_related', '5'); |
429 | ||
430 | $this->click('_qf_MembershipType_upload-bottom'); | |
431 | $this->waitForElementPresent('link=Add Membership Type'); | |
432 | $this->waitForText('crm-notification-container', "Membership Type Another $title"); | |
433 | ||
434 | // creating another Orgnization | |
435 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); | |
436 | $org2 = substr(sha1(rand()), 0, 7); | |
437 | $this->type('organization_name', "Organization $org2"); | |
438 | $this->type('email_1_email', "$org2@org.com"); | |
439 | $this->clickLink('_qf_Contact_upload_view'); | |
440 | ||
441 | // click through to the membership view screen | |
442 | $this->click('css=li#tab_member a'); | |
443 | $this->waitForElementPresent('link=Add Membership'); | |
444 | $this->click('link=Add Membership'); | |
445 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
446 | ||
447 | // fill in Membership Organization and Type | |
448 | $this->select('membership_type_id[0]', "label=Organization $title"); | |
449 | $this->select('membership_type_id[1]', "label=Membership Type Another $title"); | |
450 | ||
451 | $sourceText = 'Membership ContactAddTest with Rolling Membership Type'; | |
452 | $this->type('source', $sourceText); | |
cebea087 | 453 | $this->clickLink('_qf_Membership_upload', 'link=Add Membership', FALSE); |
385f7a49 | 454 | $this->waitForTextPresent($sourceText); |
455 | ||
456 | // Is status message correct? | |
457 | $this->waitForText('crm-notification-container', "Membership Type Another $title"); | |
458 | ||
459 | // edit contact | |
460 | $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid", "_qf_Contact_cancel-bottom"); | |
461 | ||
462 | // change Current Employer | |
cebea087 | 463 | $this->select2('employer_id', $org2); |
385f7a49 | 464 | $this->clickLink("_qf_Contact_upload_view-bottom"); |
465 | ||
466 | // click through to the membership view screen | |
467 | $this->click('css=li#tab_member a'); | |
468 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
469 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em")); | |
cebea087 | 470 | $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href")); |
471 | $actualMembershipId2 = $url['queryString']['id']; | |
385f7a49 | 472 | |
473 | // click through to the activity view screen | |
474 | $this->click('css=li#tab_activity a'); | |
895231b4 | 475 | $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); |
385f7a49 | 476 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
895231b4 | 477 | $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']@href")); |
cebea087 | 478 | $actualMembershipActivityId2 = $url['queryString']['id']; |
385f7a49 | 479 | |
480 | // verify membership id and membership activity id with previous one | |
481 | $this->assertNotEquals($expectedMembershipId, $actualMembershipId2); | |
482 | $this->assertNotEquals($expectedMembershipId, $actualMembershipActivityId2); | |
483 | ||
484 | // click through to the relationship view screen | |
485 | $this->click('css=li#tab_rel a'); | |
cebea087 | 486 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
487 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org2']")); | |
385f7a49 | 488 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
489 | ||
490 | // creating another Orgnization with no membership | |
491 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); | |
492 | $org3 = substr(sha1(rand()), 0, 7); | |
493 | $this->type('organization_name', "Organization $org3"); | |
494 | $this->type('email_1_email', "$org3@org.com"); | |
495 | $this->clickLink('_qf_Contact_upload_view'); | |
496 | ||
497 | // edit contact | |
498 | $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid", "_qf_Contact_cancel-bottom"); | |
499 | ||
500 | // change Current Employer | |
cebea087 | 501 | $this->select2('employer_id', $org3); |
385f7a49 | 502 | $this->clickLink("_qf_Contact_upload_view-bottom"); |
503 | ||
504 | // click through to the membership view screen | |
505 | $this->click('css=li#tab_member a'); | |
cebea087 | 506 | |
a63c43ee | 507 | $this->waitForAjaxContent(); |
508 | $this->waitForTextPresent("No memberships have been recorded for this contact."); | |
385f7a49 | 509 | $this->assertEquals(0, $this->getText("xpath=//li[@id='tab_member']/a/em")); |
510 | ||
511 | // click through to the activity view screen | |
512 | $this->click('css=li#tab_activity a'); | |
895231b4 | 513 | $this->waitForText("xpath=//table[@class='contact-activity-selector-activity crm-ajax-table dataTable no-footer']/tbody/tr/td", "None found."); |
385f7a49 | 514 | $this->assertEquals(0, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
515 | ||
516 | // click through to the relationship view screen | |
517 | $this->click('css=li#tab_rel a'); | |
cebea087 | 518 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
519 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org3']")); | |
385f7a49 | 520 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
521 | } | |
96025800 | 522 | |
6a488035 | 523 | } |