Merge pull request #2991 from colemanw/master
[civicrm-core.git] / tests / phpunit / WebTest / Pledge / StandaloneAddDeleteTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
06a1bc01 4 | CiviCRM version 4.5 |
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
TO
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28class WebTest_Pledge_StandaloneAddDeleteTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testStandalonePledgeAddDelete() {
6a488035
TO
35 $this->webtestLogin();
36
d2771e94 37 $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload');
6a488035
TO
38
39 // create new contact using dialog
40 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
41 $lastName = 'Za' . substr(sha1(rand()), 0, 7);
42 $this->webtestNewDialogContact($firstName, $lastName, $firstName . '@example.com');
43
44 $this->type('amount', '2400');
45 $this->type('installments', '10');
46 $this->select('frequency_unit', 'value=month');
47 $this->type('frequency_day', '2');
48 $this->webtestFillDate('acknowledge_date', 'now');
49 $this->select('contribution_page_id', 'value=3');
50 $this->click('_qf_Pledge_upload-bottom');
51 $this->waitForPageToLoad("30000");
52
6c5f7368 53 $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
6a488035
TO
54
55 // verify if Pledge is created
45fabf8e 56 $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
6a488035
TO
57
58 //click through to the Pledge view screen
45fabf8e 59 $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
6a488035
TO
60 $this->waitForElementPresent('_qf_PledgeView_next-bottom');
61 $pledgeDate = date('F jS, Y', strtotime('now'));
62
63 $this->webtestVerifyTabularData(array(
64 'Pledge By' => $firstName . ' ' . $lastName,
65 'Total Pledge Amount' => '$ 2,400.00',
66 'To be paid in' => '10 installments of $ 240.00 every 1 month(s)',
67 'Payments are due on the' => '2 day of the period',
68 'Pledge Made' => $pledgeDate,
69 'Financial Type' => 'Donation',
70 'Pledge Status' => 'Pending',
71 )
72 );
45fabf8e 73 $this->clickLink('_qf_PledgeView_next-bottom', "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']", FALSE);
74 $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a");
75 $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a[text()='Record Payment (Check, Cash, EFT ...)']");
76 $this->click("xpath=//div[@class='view-content']//table//tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a");
6a488035
TO
77 $this->waitForElementPresent("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
78 $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
79 $this->type('total_amount', '300.00');
76e86fd8
CW
80 $this->click('_qf_Contribution_upload-bottom');
81
d2771e94 82 $this->waitForPageToLoad("30000");
6c5f7368 83 $this->waitForText('crm-notification-container', "The contribution record has been saved.");
76e86fd8 84
45fabf8e 85 $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
86 $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a");
87 $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[8]/a[text()='Record Payment (Check, Cash, EFT ...)']");
88 $this->click("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[8]/a");
6a488035
TO
89 $this->waitForElementPresent("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
90 $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
91 $this->type('total_amount', '250.00');
92 $this->click('_qf_Contribution_upload-bottom');
d2771e94 93 $this->waitForPageToLoad("30000");
6c5f7368 94 $this->waitForText('crm-notification-container', "The contribution record has been saved.");
76e86fd8 95
45fabf8e 96 $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
97 $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a");
98 $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[4]/td[8]/a[text()='Record Payment (Check, Cash, EFT ...)']");
99 $this->click("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[4]/td[8]/a");
6a488035 100 $this->waitForElementPresent("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
76e86fd8
CW
101 $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a");
102
6a488035
TO
103 $this->type('total_amount', '170.00');
104 $this->click('_qf_Contribution_upload-bottom');
d2771e94 105 $this->waitForPageToLoad("30000");
6c5f7368 106 $this->waitForText('crm-notification-container', "The contribution record has been saved.");
76e86fd8 107
6a488035 108 // delete the contribution associated with the 2nd payment
45fabf8e 109 $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']");
110 $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a");
111 $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[8]/a[text()='View Payment']");
112 $this->click("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[8]/a");
6a488035
TO
113 $this->waitForElementPresent("xpath=//form[@id='ContributionView']//div[2]/div/div/a[2]");
114 $this->click("xpath=//form[@id='ContributionView']//div[2]/div/div/a[2]");
115 $this->waitForElementPresent("_qf_Contribution_next-bottom");
116 $this->click("_qf_Contribution_next-bottom");
45fabf8e 117 $this->waitForElementPresent("ui-id-4");
118 $this->click("ui-id-4");
119 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[10]/span/a[text()='View']");
120 $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a");
121 $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[7]");
76e86fd8 122
45fabf8e 123 $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[7]","Pending");
124 $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td");
76e86fd8 125
6a488035 126 // verify that payment owed amount is correct (250.00)
45fabf8e 127 $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td","250.00");
6a488035 128 // verify that Total Paid and Balance sums are correct
45fabf8e 129 $this->verifyText("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[3]","470.00");
130 $this->verifyText("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[4]","1,930.00");
76e86fd8 131
6a488035
TO
132 }
133}
134