Commit | Line | Data |
---|---|---|
b879962e DG |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
b879962e | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
b879962e DG |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
b879962e DG |
26 | |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Pledge_AddCancelPaymentTest | |
31 | */ | |
b879962e DG |
32 | class WebTest_Pledge_AddCancelPaymentTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testAddCancelPayment() { |
b879962e DG |
39 | $this->webtestLogin(); |
40 | ||
41 | $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload'); | |
42 | ||
43 | // create new contact using dialog | |
80f3b91d | 44 | $contact = $this->createDialogContact(); |
b879962e DG |
45 | |
46 | $this->type('amount', '1200'); | |
47 | $this->type('installments', '12'); | |
48 | $this->select('frequency_unit', 'value=month'); | |
49 | $this->type('frequency_day', '1'); | |
50 | $this->webtestFillDate('acknowledge_date', 'now'); | |
51 | $this->select('contribution_page_id', 'value=3'); | |
52 | $this->click('_qf_Pledge_upload-bottom'); | |
53 | $this->waitForPageToLoad("30000"); | |
54 | ||
55 | $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); | |
56 | ||
57 | // verify if Pledge is created | |
45fabf8e | 58 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
b879962e DG |
59 | |
60 | //click through to the Pledge view screen | |
45fabf8e | 61 | $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
b879962e DG |
62 | $this->waitForElementPresent('_qf_PledgeView_next-bottom'); |
63 | $pledgeDate = date('F jS, Y', strtotime('now')); | |
64 | ||
65 | $this->webtestVerifyTabularData(array( | |
80f3b91d | 66 | 'Pledge By' => $contact['display_name'], |
b879962e DG |
67 | 'Total Pledge Amount' => '$ 1,200.00', |
68 | 'To be paid in' => '12 installments of $ 100.00 every 1 month(s)', | |
69 | 'Payments are due on the' => '1 day of the period', | |
70 | 'Pledge Made' => $pledgeDate, | |
71 | 'Financial Type' => 'Donation', | |
72 | 'Pledge Status' => 'Pending', | |
73 | ) | |
74 | ); | |
b879962e | 75 | //Edit and add the first payment for 300.00 |
23c608b0 | 76 | $this->click('_qf_PledgeView_next-bottom'); |
2913f26f | 77 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
78 | $this->waitForAjaxContent(); | |
c51f8adb | 79 | $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a"); |
c51f8adb | 80 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody//tr//td/table/tbody/tr[2]/td[8]/a[text()='Record Payment']"); |
45fabf8e | 81 | $this->click("xpath=//div[@class='view-content']//table//tbody//tr//td/table/tbody/tr[2]/td[8]/a"); |
b879962e DG |
82 | $this->waitForElementPresent("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a"); |
83 | $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a"); | |
84 | $this->type('total_amount', '300.00'); | |
85 | $this->click('_qf_Contribution_upload-bottom'); | |
b879962e DG |
86 | $this->waitForText('crm-notification-container', "The contribution record has been saved."); |
87 | ||
45fabf8e | 88 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
89 | $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a"); | |
b879962e | 90 | |
e9479dcf | 91 | //Check whether the next two payments are done or not |
38653166 | 92 | $this->waitForAjaxContent(); |
683948a3 | 93 | $this->waitForElementPresent("xpath=//form[@id='Search']//div/table/tbody//tr//td/table/tbody/tr[2]/td[8]/a[text()='View Payment']"); |
6c6e6187 TO |
94 | $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[7]", "Completed"); |
95 | $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[4]/td[7]", "Completed"); | |
b879962e | 96 | |
b879962e | 97 | //Cancel the contribution made for amount of 300.00 |
683948a3 | 98 | $this->waitForElementPresent("xpath=//form[@id='Search']//div/table/tbody//tr//td/table/tbody/tr[2]/td[8]/a[text()='View Payment']"); |
45fabf8e | 99 | $this->click("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a"); |
b879962e DG |
100 | $this->waitForElementPresent("xpath=//form[@id='ContributionView']//div[2]/div/div/a"); |
101 | $this->click("xpath=//form[@id='ContributionView']//div[2]/div/div/a"); | |
e9479dcf | 102 | $this->waitForElementPresent("_qf_Contribution_upload-bottom"); |
b879962e | 103 | $this->select('contribution_status_id', 'value=3'); |
e9479dcf | 104 | $this->click("_qf_Contribution_upload-bottom"); |
4a058f26 | 105 | $this->waitForAjaxContent(); |
c51f8adb JP |
106 | $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); |
107 | $this->click("_qf_ContributionView_cancel-bottom"); | |
b879962e | 108 | |
45fabf8e | 109 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
2913f26f | 110 | $this->waitForAjaxContent(); |
45fabf8e | 111 | $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[1]/span/a"); |
112 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[7]"); | |
e9479dcf | 113 | |
b879962e | 114 | // verify that first paayment is cancelled and the rest two payments are revert back to the pending status |
6c6e6187 TO |
115 | $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[7]", "Cancelled"); |
116 | $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[7]", "Pending"); | |
117 | $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[4]/td[7]", "Pending"); | |
b879962e DG |
118 | |
119 | // Check whether a new payment with pending status is added at the last or not | |
6c6e6187 | 120 | $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[14]/td[7]", "Pending"); |
b879962e DG |
121 | |
122 | // verify that Balance sum is correct | |
f6dd1ca6 | 123 | $this->verifyText("xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']//div[@class='view-content']//table//tbody/tr[1]/td[4]", "1,200.00"); |
b879962e DG |
124 | |
125 | } | |
96025800 | 126 | |
b879962e | 127 | } |