phpcs - Fix error, "Expected 1 newline at end of file; XXX found".
[civicrm-core.git] / tests / phpunit / WebTest / Pledge / ContactContextAddTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035 5 +--------------------------------------------------------------------+
06a1bc01 6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 +--------------------------------------------------------------------+
25*/
26
6a488035 27require_once 'CiviTest/CiviSeleniumTestCase.php';
e9479dcf
EM
28
29/**
30 * Class WebTest_Pledge_ContactContextAddTest
31 */
6a488035
TO
32class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
00be9182 38 public function testContactContextAddTest() {
6a488035 39 $this->webtestLogin();
400ed621
DG
40 // Disable pop-ups for this test. Running test w/ pop-ups causes a spurious failure. dgg
41 $this->enableDisablePopups(FALSE);
6a488035
TO
42
43 // create unique name
44 $name = substr(sha1(rand()), 0, 7);
45 $firstName = 'Adam' . $name;
46 $lastName = 'Jones' . $name;
47
48 // create new contact
49 $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com");
50
51 // wait for action element
52 $this->waitForElementPresent('crm-contact-actions-link');
53
54 // now add pledge from contact summary
55 $this->click("//a[@id='crm-contact-actions-link']/span/div");
56
57 // wait for add plegde link
58 $this->waitForElementPresent('link=Add Pledge');
59
60 $this->click('link=Add Pledge');
61
62 // wait for pledge form to load completely
63 $this->waitForElementPresent('_qf_Pledge_upload-bottom');
64
65 // check contact name on pledge form
d2771e94 66 $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName");
6a488035 67
6a488035
TO
68 $this->type("amount", "100");
69 $this->type("installments", "10");
70 $this->select("frequency_unit", "value=week");
71 $this->type("frequency_day", "2");
72
73 $this->webtestFillDate('acknowledge_date', 'now');
74
75 $this->select("contribution_page_id", "value=3");
76
6a488035
TO
77
78 //PaymentReminders
79 $this->click("PaymentReminders");
80 $this->waitForElementPresent("additional_reminder_day");
81 $this->type("initial_reminder_day", "4");
82 $this->type("max_reminders", "2");
83 $this->type("additional_reminder_day", "4");
84
85 $this->click("_qf_Pledge_upload-bottom");
6a488035 86
6c5f7368 87 $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
6a488035 88
45fabf8e 89 $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
6a488035 90 //click through to the Pledge view screen
45fabf8e 91 $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']");
6a488035
TO
92 $this->waitForElementPresent("_qf_PledgeView_next-bottom");
93 $pledgeDate = date('F jS, Y', strtotime('now'));
94
95 $verifyData = array(
96 'Pledge By' => $firstName . ' ' . $lastName,
97 'Total Pledge Amount' => '$ 100.00',
98 'To be paid in' => '10 installments of $ 10.00 every 1 week(s)',
99 'Payments are due on the' => '2 day of the period',
100 'Pledge Made' => $pledgeDate,
101 'Financial Type' => 'Donation',
102 'Pledge Status' => 'Pending',
6a488035
TO
103 'Initial Reminder Day' => '4 days prior to schedule date',
104 'Maximum Reminders Send' => 2,
105 'Send additional reminders' => '4 days after the last one sent',
106 );
107
108 foreach ($verifyData as $label => $value) {
109 $this->verifyText("xpath=//form[@id='PledgeView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value));
110 }
111
45fabf8e 112 $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']", FALSE);
48b420d7 113
169535ea 114 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a");
45fabf8e 115 $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a");
169535ea 116 $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody//tr//td[2]/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
400ed621
DG
117 // Re-enable pop-ups to leave things in the same state
118 $this->enableDisablePopups(TRUE);
6a488035
TO
119 }
120}