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