Merge branch 'rcsheets-docstring-cleanup'
[civicrm-core.git] / tests / phpunit / WebTest / Pledge / ContactContextAddTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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 class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testContactContextAddTest() {
35 $this->webtestLogin();
36
37 // create unique name
38 $name = substr(sha1(rand()), 0, 7);
39 $firstName = 'Adam' . $name;
40 $lastName = 'Jones' . $name;
41
42 // create new contact
43 $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com");
44
45 // wait for action element
46 $this->waitForElementPresent('crm-contact-actions-link');
47
48 // now add pledge from contact summary
49 $this->click("//a[@id='crm-contact-actions-link']/span/div");
50
51 // wait for add plegde link
52 $this->waitForElementPresent('link=Add Pledge');
53
54 $this->click('link=Add Pledge');
55
56 // wait for pledge form to load completely
57 $this->waitForElementPresent('_qf_Pledge_upload-bottom');
58
59 // check contact name on pledge form
60 $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName");
61
62 $this->type("amount", "100");
63 $this->type("installments", "10");
64 $this->select("frequency_unit", "value=week");
65 $this->type("frequency_day", "2");
66
67 $this->webtestFillDate('acknowledge_date', 'now');
68
69 $this->select("contribution_page_id", "value=3");
70
71 //Honoree section
72 $this->click("Honoree");
73 $this->waitForElementPresent("honor_email");
74
75 $this->click("CIVICRM_QFID_1_2");
76 $this->select("honor_prefix_id", "value=3");
77
78 $honreeFirstName = 'First' . substr(sha1(rand()), 0, 4);
79 $honreeLastName = 'last' . substr(sha1(rand()), 0, 7);
80 $this->type("honor_first_name", $honreeFirstName);
81 $this->type("honor_last_name", $honreeLastName);
82 $this->type("honor_email", $honreeFirstName . "@example.com");
83
84 //PaymentReminders
85 $this->click("PaymentReminders");
86 $this->waitForElementPresent("additional_reminder_day");
87 $this->type("initial_reminder_day", "4");
88 $this->type("max_reminders", "2");
89 $this->type("additional_reminder_day", "4");
90
91 $this->click("_qf_Pledge_upload-bottom");
92 $this->waitForPageToLoad($this->getTimeoutMsec());
93
94 $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
95
96 $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
97 //click through to the Pledge view screen
98 $this->click("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
99 $this->waitForElementPresent("_qf_PledgeView_next-bottom");
100 $pledgeDate = date('F jS, Y', strtotime('now'));
101
102 $verifyData = array(
103 'Pledge By' => $firstName . ' ' . $lastName,
104 'Total Pledge Amount' => '$ 100.00',
105 'To be paid in' => '10 installments of $ 10.00 every 1 week(s)',
106 'Payments are due on the' => '2 day of the period',
107 'Pledge Made' => $pledgeDate,
108 'Financial Type' => 'Donation',
109 'Pledge Status' => 'Pending',
110 'In Honor of' => 'Mr. ' . $honreeFirstName . ' ' . $honreeLastName,
111 'Initial Reminder Day' => '4 days prior to schedule date',
112 'Maximum Reminders Send' => 2,
113 'Send additional reminders' => '4 days after the last one sent',
114 );
115
116 foreach ($verifyData as $label => $value) {
117 $this->verifyText("xpath=//form[@id='PledgeView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
118 }
119
120 $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
121 $this->click("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[1]/span/a");
122 $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody//tr//td[2]/table/tbody/tr[2]/td[8]/a[text()='Record Payment (Check, Cash, EFT ...)']");
123 }
124 }
125