Import from SVN (r45945, r596)
[civicrm-core.git] / tests / phpunit / WebTest / Pledge / ContactContextAddTest.php
CommitLineData
6a488035
TO
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
28require_once 'CiviTest/CiviSeleniumTestCase.php';
29class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testContactContextAddTest() {
36 // This is the path where our testing install resides.
37 // The rest of URL is defined in CiviSeleniumTestCase base class, in
38 // class attributes.
39 $this->open($this->sboxPath);
40
41 // Logging in. Remember to wait for page to load. In most cases,
42 // you can rely on 30000 as the value that allows your test to pass, however,
43 // sometimes your test might fail because of this. In such cases, it's better to pick one element
44 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
45 // page contents loaded and you can continue your test execution.
46 $this->webtestLogin();
47
48 // create unique name
49 $name = substr(sha1(rand()), 0, 7);
50 $firstName = 'Adam' . $name;
51 $lastName = 'Jones' . $name;
52
53 // create new contact
54 $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com");
55
56 // wait for action element
57 $this->waitForElementPresent('crm-contact-actions-link');
58
59 // now add pledge from contact summary
60 $this->click("//a[@id='crm-contact-actions-link']/span/div");
61
62 // wait for add plegde link
63 $this->waitForElementPresent('link=Add Pledge');
64
65 $this->click('link=Add Pledge');
66
67 // wait for pledge form to load completely
68 $this->waitForElementPresent('_qf_Pledge_upload-bottom');
69
70 // check contact name on pledge form
71 $this->assertTrue($this->isTextPresent("$firstName $lastName"));
72
73 // Let's start filling the form with values.
74 $this->type("amount", "100");
75 $this->type("installments", "10");
76 $this->select("frequency_unit", "value=week");
77 $this->type("frequency_day", "2");
78
79 $this->webtestFillDate('acknowledge_date', 'now');
80
81 $this->select("contribution_page_id", "value=3");
82
83 //Honoree section
84 $this->click("Honoree");
85 $this->waitForElementPresent("honor_email");
86
87 $this->click("CIVICRM_QFID_1_2");
88 $this->select("honor_prefix_id", "value=3");
89
90 $honreeFirstName = 'First' . substr(sha1(rand()), 0, 4);
91 $honreeLastName = 'last' . substr(sha1(rand()), 0, 7);
92 $this->type("honor_first_name", $honreeFirstName);
93 $this->type("honor_last_name", $honreeLastName);
94 $this->type("honor_email", $honreeFirstName . "@example.com");
95
96 //PaymentReminders
97 $this->click("PaymentReminders");
98 $this->waitForElementPresent("additional_reminder_day");
99 $this->type("initial_reminder_day", "4");
100 $this->type("max_reminders", "2");
101 $this->type("additional_reminder_day", "4");
102
103 $this->click("_qf_Pledge_upload-bottom");
104 $this->waitForPageToLoad($this->getTimeoutMsec());
105
106 $this->assertTrue($this->isTextPresent("Pledge has been recorded and the payment schedule has been created."));
107
108 $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
109 //click through to the Pledge view screen
110 $this->click("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
111 $this->waitForElementPresent("_qf_PledgeView_next-bottom");
112 $pledgeDate = date('F jS, Y', strtotime('now'));
113
114 $verifyData = array(
115 'Pledge By' => $firstName . ' ' . $lastName,
116 'Total Pledge Amount' => '$ 100.00',
117 'To be paid in' => '10 installments of $ 10.00 every 1 week(s)',
118 'Payments are due on the' => '2 day of the period',
119 'Pledge Made' => $pledgeDate,
120 'Financial Type' => 'Donation',
121 'Pledge Status' => 'Pending',
122 'In Honor of' => 'Mr. ' . $honreeFirstName . ' ' . $honreeLastName,
123 'Initial Reminder Day' => '4 days prior to schedule date',
124 'Maximum Reminders Send' => 2,
125 'Send additional reminders' => '4 days after the last one sent',
126 );
127
128 foreach ($verifyData as $label => $value) {
129 $this->verifyText("xpath=//form[@id='PledgeView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
130 }
131
132 $this->click("_qf_PledgeView_next-bottom");
133 $this->waitForPageToLoad($this->getTimeoutMsec());
134
135 $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
136 $this->click("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[1]/span/a");
137 $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody//tr//td[2]/table/tbody/tr[2]/td[8]/a[text()='Record Payment (Check, Cash, EFT ...)']");
138 }
139}
140