Merge pull request #4875 from civicrm/minor-fix
[civicrm-core.git] / tests / phpunit / WebTest / Member / FixedMembershipTypeTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Member_FixedMembershipTypeTest
31 */
32 class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testMembershipTypeScenario1() {
39 // Scenario 1
40 // Rollover Date < Start Date
41 // Join Date > Rollover Date and Join Date < Start Date
42
43 // Log in using webtestLogin() method
44 $this->webtestLogin();
45
46 $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
47
48 $title = substr(sha1(rand()), 0, 7);
49 $this->type('organization_name', "Organization $title");
50 $this->type('email_1_email', "$title@org.com");
51 $this->click('_qf_Contact_upload_view');
52 $this->waitForPageToLoad($this->getTimeoutMsec());
53
54 $this->assertTrue($this->isTextPresent("Organization $title has been created."));
55
56 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
57
58 $this->click("link=Add Membership Type");
59 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
60
61 $this->type('name', "Membership Type $title");
62 $this->select2('member_of_contact_id', $title);
63
64 $this->type('minimum_fee', '100');
65 $this->select('financial_type_id', 'value=2');
66 $this->type('duration_interval', 1);
67 $this->select('duration_unit', "label=year");
68
69 $this->select('period_type', "value=fixed");
70 $this->waitForElementPresent('fixed_period_rollover_day[d]');
71
72 // fixed period start set to April 1
73 $this->select('fixed_period_start_day[M]', 'value=4');
74 // rollover date set to Jan 31
75 $this->select('fixed_period_rollover_day[M]', 'value=1');
76
77 $this->click('relationship_type_id', 'value=4_b_a');
78
79 $this->click('_qf_MembershipType_upload-bottom');
80 $this->waitForElementPresent('link=Add Membership Type');
81 $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
82
83 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
84
85 $firstName = "John_" . substr(sha1(rand()), 0, 7);
86
87 //fill in first name
88 $this->type('first_name', $firstName);
89
90 //fill in last name
91 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
92 $this->type('last_name', $lastName);
93
94 //fill in email
95 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
96 $this->type('email_1_email', $email);
97
98 // Clicking save.
99 $this->click('_qf_Contact_upload_view');
100 $this->waitForPageToLoad($this->getTimeoutMsec());
101 $this->assertTrue($this->isTextPresent("$firstName $lastName has been created."));
102
103 // click through to the membership view screen
104 $this->click('css=li#tab_member a');
105
106 $this->waitForElementPresent('link=Add Membership');
107 $this->click('link=Add Membership');
108
109 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
110
111 // fill in Membership Organization and Type
112 $this->select('membership_type_id[0]', "label=Organization $title");
113 $this->select('membership_type_id[1]', "label=Membership Type $title");
114
115 $sourceText = "Membership ContactAddTest with Fixed Membership Type";
116 // fill in Source
117 $this->type('source', $sourceText);
118
119 //build the membership dates.
120 require_once 'CRM/Core/Config.php';
121 require_once 'CRM/Utils/Array.php';
122 require_once 'CRM/Utils/Date.php';
123 $currentYear = date('Y');
124 $currentMonth = date('m');
125 $previousYear = $currentYear - 1;
126 $nextYear = $currentYear + 1;
127
128 $todayDate = date('Y-m-d');
129
130 // the member-since date we will type in to membership form
131 $joinDate = date('Y-m-d', mktime(0, 0, 0, 3, 25, $currentYear));
132
133 // expected calc'd start date
134 $startDate = date('Y-m-d', mktime(0, 0, 0, 4, 1, $previousYear));
135
136 // expected calc'd end date
137 $endDate = date('Y-m-d', mktime(0, 0, 0, 3, 31, $nextYear));
138
139 $configVars = new CRM_Core_Config_Variables();
140 foreach (array(
141 'joinDate',
142 'startDate',
143 'endDate'
144 ) as $date) {
145 $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
146 }
147
148 $query = "
149 SELECT end_event_adjust_interval
150
151 FROM civicrm_membership_status
152
153 WHERE start_event = 'join_date'
154 AND name = 'New'";
155 $endInterval = CRM_Core_DAO::singleValueQuery($query);
156
157 // Add endInterval to March 25 (join date month above) to get end of New status period
158 $endNewStatus = date('Y-m-d', mktime(0, 0, 0, $endInterval + 3, 25, $currentYear));
159
160 $status = 'Current';
161 // status will be 'New' if today is >= join date and <= endNewStatus date
162 if ((strtotime($todayDate) >= strtotime($joinDate)) && (strtotime($todayDate) <= strtotime($endNewStatus))) {
163 $status = 'New';
164 }
165
166 // fill in Join Date
167 $this->webtestFillDate('join_date', $joinDate);
168
169 // Clicking save.
170 $this->click('_qf_Membership_upload');
171
172 // page was loaded
173 $this->waitForTextPresent($sourceText);
174
175 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
176 // Is status message correct?
177 $this->assertTrue($this->isTextPresent("Membership Type $title membership for $firstName $lastName has been added."),
178 "Status message didn't show up after saving!"
179 );
180
181 // click through to the membership view screen
182 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
183 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
184
185 $this->webtestVerifyTabularData(
186 array(
187 'Membership Type' => "Membership Type $title",
188 'Status' => $status,
189 'Source' => $sourceText,
190 'Member Since' => $joinDate,
191 'Start date' => $startDate,
192 'End date' => $endDate,
193 )
194 );
195 }
196
197 public function testMembershipTypeScenario2() {
198 // Scenario 2
199 // Rollover Date < Join Date
200
201 // Log in using webtestLogin() method
202 $this->webtestLogin();
203
204 $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
205
206 $title = substr(sha1(rand()), 0, 7);
207 $this->type('organization_name', "Organization $title");
208 $this->type('email_1_email', "$title@org.com");
209 $this->click('_qf_Contact_upload_view');
210 $this->waitForPageToLoad($this->getTimeoutMsec());
211
212 $this->assertTrue($this->isTextPresent("Organization $title has been created."));
213
214 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
215
216 $this->click("link=Add Membership Type");
217 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
218
219 $this->type('name', "Membership Type $title");
220 $this->select2('member_of_contact_id', $title);
221
222 $this->type('minimum_fee', '100');
223 $this->select('financial_type_id', 'value=2');
224
225 $this->type('duration_interval', 2);
226 $this->select('duration_unit', "label=year");
227
228 $this->select('period_type', "value=fixed");
229 $this->waitForElementPresent('fixed_period_rollover_day[d]');
230
231 $this->select('fixed_period_start_day[M]', 'value=9');
232 $this->select('fixed_period_rollover_day[M]', 'value=6');
233 $this->select('fixed_period_rollover_day[d]', 'value=30');
234
235 $this->click('relationship_type_id', 'value=4_b_a');
236
237 $this->click('_qf_MembershipType_upload-bottom');
238 $this->waitForElementPresent('link=Add Membership Type');
239 $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
240
241 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
242
243 $firstName = "John_" . substr(sha1(rand()), 0, 7);
244
245 //fill in first name
246 $this->type('first_name', $firstName);
247
248 //fill in last name
249 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
250 $this->type('last_name', $lastName);
251
252 //fill in email
253 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
254 $this->type('email_1_email', $email);
255
256 // Clicking save.
257 $this->click('_qf_Contact_upload_view');
258 $this->waitForPageToLoad($this->getTimeoutMsec());
259
260 $this->assertTrue($this->isTextPresent("$firstName $lastName has been created."));
261
262 // click through to the membership add screen
263 $this->click('css=li#tab_member a');
264
265 $this->waitForElementPresent('link=Add Membership');
266 $this->click('link=Add Membership');
267
268 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
269
270 // fill in Membership Organization and Type
271 $this->select('membership_type_id[0]', "label=Organization {$title}");
272 // Wait for membership type select to reload
273 $this->waitForTextPresent("Membership Type {$title}");
274 $this->select('membership_type_id[1]', "label=Membership Type {$title}");
275
276 $sourceText = "Membership ContactAddTest with Fixed Membership Type Scenario 2";
277 // fill in Source
278 $this->type('source', $sourceText);
279
280 //build the membership dates.
281 require_once 'CRM/Core/Config.php';
282 require_once 'CRM/Utils/Array.php';
283 require_once 'CRM/Utils/Date.php';
284 $currentYear = date('Y');
285 $currentMonth = date('m');
286 $previousYear = $currentYear - 1;
287
288 $todayDate = date('Y-m-d');
289
290 // the member-since date we will type in to membership form
291 $joinDate = date('Y-m-d', mktime(0, 0, 0, 7, 15, $currentYear));
292
293 // expected calc'd start date
294 $startDate = date('Y-m-d', mktime(0, 0, 0, 9, 1, $previousYear));
295
296 // expected calc'd end date
297 $endDate = date('Y-m-d', mktime(0, 0, 0, 8, 31, $currentYear + 2));
298 $configVars = new CRM_Core_Config_Variables();
299 foreach (array(
300 'joinDate',
301 'startDate',
302 'endDate'
303 ) as $date) {
304 $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
305 }
306
307 $query = "
308 SELECT end_event_adjust_interval
309
310 FROM civicrm_membership_status
311
312 WHERE start_event = 'join_date'
313 AND name = 'New'";
314 $endInterval = CRM_Core_DAO::singleValueQuery($query);
315
316 // Add endInterval to July 15 (join date month above) to get end of New status period
317 $endNewStatus = date('Y-m-d', mktime(0, 0, 0, $endInterval + 7, 15, $currentYear));
318
319 $status = 'Current';
320 // status will be 'New' if today is >= join date and <= endNewStatus date
321 if ((strtotime($todayDate) >= strtotime($joinDate)) && (strtotime($todayDate) <= strtotime($endNewStatus))) {
322 $status = 'New';
323 }
324
325 // fill in Join Date
326 $this->webtestFillDate('join_date', $joinDate);
327
328 // Clicking save.
329 $this->click('_qf_Membership_upload');
330 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
331
332 // page was loaded
333 $this->waitForTextPresent($sourceText);
334
335 // Is status message correct?
336 $this->assertTrue($this->isTextPresent("Membership Type $title membership for $firstName $lastName has been added."),
337 "Status message didn't show up after saving!"
338 );
339
340 // click through to the membership view screen
341 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
342 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
343
344 $this->webtestVerifyTabularData(
345 array(
346 'Membership Type' => "Membership Type {$title}",
347 'Status' => $status,
348 'Source' => $sourceText,
349 'Member Since' => $joinDate,
350 'Start date' => $startDate,
351 'End date' => $endDate,
352 )
353 );
354 }
355
356 public function testMembershipTypeScenario3() {
357 // Scenario 3
358 // Standard Fixed scenario - Jan 1 Fixed Period Start and October 31 rollover
359 // Join Date is later than Rollover Date
360
361 // Log in using webtestLogin() method
362 $this->webtestLogin();
363
364 $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
365
366 $title = substr(sha1(rand()), 0, 7);
367 $this->type('organization_name', "Organization $title");
368 $this->type('email_1_email', "$title@org.com");
369 $this->click('_qf_Contact_upload_view');
370 $this->waitForPageToLoad($this->getTimeoutMsec());
371
372 $this->assertTrue($this->isTextPresent("Organization $title has been created."));
373
374 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
375
376 $this->click("link=Add Membership Type");
377 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
378
379 $this->type('name', "Membership Type $title");
380 $this->select2('member_of_contact_id', $title);
381
382 $this->type('minimum_fee', '100');
383 $this->select('financial_type_id', 'value=2');
384 $this->type('duration_interval', 1);
385 $this->select('duration_unit', "label=year");
386
387 $this->select('period_type', "value=fixed");
388 $this->waitForElementPresent('fixed_period_rollover_day[d]');
389
390 $this->select('fixed_period_rollover_day[M]', 'value=10');
391 $this->select('fixed_period_rollover_day[d]', 'value=31');
392
393 $this->click('relationship_type_id', 'value=4_b_a');
394
395 $this->click('_qf_MembershipType_upload-bottom');
396 $this->waitForElementPresent('link=Add Membership Type');
397
398 $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
399 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
400
401 $firstName = "John_" . substr(sha1(rand()), 0, 7);
402
403 //fill in first name
404 $this->type('first_name', $firstName);
405
406 //fill in last name
407 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
408 $this->type('last_name', $lastName);
409
410 //fill in email
411 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
412 $this->type('email_1_email', $email);
413
414 // Clicking save.
415 $this->click('_qf_Contact_upload_view');
416 $this->waitForPageToLoad($this->getTimeoutMsec());
417
418 $this->assertTrue($this->isTextPresent("$firstName $lastName has been created."));
419
420 // click through to the membership view screen
421 $this->click('css=li#tab_member a');
422
423 $this->waitForElementPresent('link=Add Membership');
424 $this->click('link=Add Membership');
425
426 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
427
428 // fill in Membership Organization and Type
429 $this->select('membership_type_id[0]', "label=Organization {$title}");
430 // Wait for membership type select to reload
431 $this->waitForTextPresent("Membership Type {$title}");
432 $this->select('membership_type_id[1]', "label=Membership Type {$title}");
433
434 $sourceText = "Membership ContactAddTest with Fixed Membership Type Scenario 3";
435 // fill in Source
436 $this->type('source', $sourceText);
437
438 //build the membership dates.
439 require_once 'CRM/Core/Config.php';
440 require_once 'CRM/Utils/Array.php';
441 require_once 'CRM/Utils/Date.php';
442 $currentYear = date('Y');
443 $currentMonth = date('m');
444 $previousYear = $currentYear - 1;
445 $nextYear = $currentYear + 1;
446 $todayDate = date('Y-m-d');
447 $joinDate = date('Y-m-d', mktime(0, 0, 0, 11, 15, $currentYear));
448 $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear));
449 $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $nextYear));
450 $configVars = new CRM_Core_Config_Variables();
451 foreach (array(
452 'joinDate',
453 'startDate',
454 'endDate'
455 ) as $date) {
456 $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
457 }
458
459 $query = "
460 SELECT end_event_adjust_interval
461
462 FROM civicrm_membership_status
463
464 WHERE start_event = 'join_date'
465 AND name = 'New'";
466 $endInterval = CRM_Core_DAO::singleValueQuery($query);
467
468 // Add endInterval to Nov 15 (join date month above) to get end of New status period
469 $endNewStatus = date('Y-m-d', mktime(0, 0, 0, $endInterval - 1, 15, $nextYear));
470
471 $status = 'Current';
472 // status will be 'New' if today is >= join date and <= endNewStatus date
473 if ((strtotime($todayDate) >= strtotime($joinDate)) && (strtotime($todayDate) <= strtotime($endNewStatus))) {
474 $status = 'New';
475 }
476
477 // fill in Join Date
478 $this->webtestFillDate('join_date', $joinDate);
479
480 // Clicking save.
481 $this->click('_qf_Membership_upload');
482 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
483
484 // page was loaded
485 $this->waitForTextPresent($sourceText);
486
487 // Is status message correct?
488 $this->assertTrue($this->isTextPresent("Membership Type $title membership for $firstName $lastName has been added."),
489 "Status message didn't show up after saving!"
490 );
491
492 // click through to the membership view screen
493 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
494 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
495
496 $this->webtestVerifyTabularData(
497 array(
498 'Membership Type' => "Membership Type {$title}",
499 'Status' => $status,
500 'Source' => $sourceText,
501 'Member Since' => $joinDate,
502 'Start date' => $startDate,
503 'End date' => $endDate,
504 )
505 );
506 }
507
508 public function testMembershipTypeScenario4() {
509 // Scenario 4
510 // Standard Fixed scenario - Jan 1 Fixed Period Start and October 31 rollover
511 // Join Date is earlier than Rollover Date
512
513 // Log in using webtestLogin() method
514 $this->webtestLogin();
515
516 $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel');
517
518 $title = substr(sha1(rand()), 0, 7);
519 $this->type('organization_name', "Organization $title");
520 $this->type('email_1_email', "$title@org.com");
521 $this->click('_qf_Contact_upload_view');
522 $this->waitForPageToLoad($this->getTimeoutMsec());
523
524 $this->assertTrue($this->isTextPresent("Organization $title has been created."));
525
526 $this->openCiviPage("admin/member/membershipType", "reset=1&action=browse");
527
528 $this->click("link=Add Membership Type");
529 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
530
531 $this->type('name', "Membership Type $title");
532 $this->select2('member_of_contact_id', $title);
533
534 $this->type('minimum_fee', '100');
535 $this->select('financial_type_id', 'value=2');
536 $this->type('duration_interval', 1);
537 $this->select('duration_unit', "label=year");
538
539 $this->select('period_type', "value=fixed");
540 $this->waitForElementPresent('fixed_period_rollover_day[d]');
541
542 $this->select('fixed_period_start_day[M]', 'value=1');
543 $this->select('fixed_period_rollover_day[M]', 'value=10');
544 $this->select('fixed_period_rollover_day[d]', 'value=31');
545
546 $this->click('relationship_type_id', 'value=4_b_a');
547
548 $this->click('_qf_MembershipType_upload-bottom');
549 $this->waitForElementPresent('link=Add Membership Type');
550 $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
551
552 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
553
554 $firstName = "John_" . substr(sha1(rand()), 0, 7);
555
556 //fill in first name
557 $this->type('first_name', $firstName);
558
559 //fill in last name
560 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
561 $this->type('last_name', $lastName);
562
563 //fill in email
564 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
565 $this->type('email_1_email', $email);
566
567 // Clicking save.
568 $this->click('_qf_Contact_upload_view');
569 $this->waitForPageToLoad($this->getTimeoutMsec());
570
571 $this->assertTrue($this->isTextPresent("$firstName $lastName has been created."));
572
573 // click through to the membership view screen
574 $this->click('css=li#tab_member a');
575
576 $this->waitForElementPresent('link=Add Membership');
577 $this->click('link=Add Membership');
578
579 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
580
581 // fill in Membership Organization and Type
582 $this->select('membership_type_id[0]', "label=Organization $title");
583 $this->select('membership_type_id[1]', "label=Membership Type $title");
584
585 $sourceText = "Membership ContactAddTest with Fixed Membership Type Scenario 4";
586 // fill in Source
587 $this->type('source', $sourceText);
588
589 //build the membership dates.
590 require_once 'CRM/Core/Config.php';
591 require_once 'CRM/Utils/Array.php';
592 require_once 'CRM/Utils/Date.php';
593 $currentYear = date('Y');
594 $currentMonth = date('m');
595 $nextYear = $currentYear + 1;
596 $todayDate = date('Y-m-d');
597
598 // the member-since date we will type in to membership form
599 $joinDate = date('Y-m-d', mktime(0, 0, 0, 1, 15, $currentYear));
600
601 // expected calc'd start and end dates
602 $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear));
603 $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $currentYear));
604 $configVars = new CRM_Core_Config_Variables();
605 foreach (array(
606 'joinDate',
607 'startDate',
608 'endDate'
609 ) as $date) {
610 $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
611 }
612
613 $query = "
614 SELECT end_event_adjust_interval
615
616 FROM civicrm_membership_status
617
618 WHERE start_event = 'join_date'
619 AND name = 'New'";
620 $endInterval = CRM_Core_DAO::singleValueQuery($query);
621
622 // Add endInterval to Jan 6 (join date month above) to get end of New status period
623 $endNewStatus = date('Y-m-d', mktime(0, 0, 0, $endInterval + 1, 15, $currentYear));
624
625 $status = 'Current';
626 // status will be 'New' if today is >= join date and <= endNewStatus date
627 if ((strtotime($todayDate) >= strtotime($joinDate)) && (strtotime($todayDate) <= strtotime($endNewStatus))) {
628 $status = 'New';
629 }
630
631 // fill in Join Date
632 $this->webtestFillDate('join_date', $joinDate);
633
634 // Clicking save.
635 $this->click('_qf_Membership_upload');
636 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
637
638 // page was loaded
639 $this->waitForTextPresent($sourceText);
640
641 // Is status message correct?
642 $this->assertTrue($this->isTextPresent("Membership Type $title membership for $firstName $lastName has been added."),
643 "Status message didn't show up after saving!"
644 );
645
646 // click through to the membership view screen
647 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
648 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
649
650 $this->webtestVerifyTabularData(
651 array(
652 'Membership Type' => "Membership Type $title",
653 'Status' => $status,
654 'Source' => $sourceText,
655 'Member Since' => $joinDate,
656 'Start date' => $startDate,
657 'End date' => $endDate,
658 )
659 );
660 }
661 }