Commit | Line | Data |
---|---|---|
b879962e DG |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
b879962e | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
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 | ||
38 | function testAddCancelPayment() { | |
39 | $this->webtestLogin(); | |
40 | ||
41 | $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload'); | |
42 | ||
43 | // create new contact using dialog | |
44 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
45 | $lastName = 'Za' . substr(sha1(rand()), 0, 7); | |
46 | $this->webtestNewDialogContact($firstName, $lastName, $firstName . '@example.com'); | |
47 | ||
48 | $this->type('amount', '1200'); | |
49 | $this->type('installments', '12'); | |
50 | $this->select('frequency_unit', 'value=month'); | |
51 | $this->type('frequency_day', '1'); | |
52 | $this->webtestFillDate('acknowledge_date', 'now'); | |
53 | $this->select('contribution_page_id', 'value=3'); | |
54 | $this->click('_qf_Pledge_upload-bottom'); | |
55 | $this->waitForPageToLoad("30000"); | |
56 | ||
57 | $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); | |
58 | ||
59 | // verify if Pledge is created | |
45fabf8e | 60 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
b879962e DG |
61 | |
62 | //click through to the Pledge view screen | |
45fabf8e | 63 | $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
b879962e DG |
64 | $this->waitForElementPresent('_qf_PledgeView_next-bottom'); |
65 | $pledgeDate = date('F jS, Y', strtotime('now')); | |
66 | ||
67 | $this->webtestVerifyTabularData(array( | |
68 | 'Pledge By' => $firstName . ' ' . $lastName, | |
69 | 'Total Pledge Amount' => '$ 1,200.00', | |
70 | 'To be paid in' => '12 installments of $ 100.00 every 1 month(s)', | |
71 | 'Payments are due on the' => '1 day of the period', | |
72 | 'Pledge Made' => $pledgeDate, | |
73 | 'Financial Type' => 'Donation', | |
74 | 'Pledge Status' => 'Pending', | |
75 | ) | |
76 | ); | |
45fabf8e | 77 | $this->clickLink('_qf_PledgeView_next-bottom', "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']", FALSE); |
78 | $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a"); | |
b879962e | 79 | //Edit and add the first payment for 300.00 |
45fabf8e | 80 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody//tr//td/table/tbody/tr[2]/td[8]/a[text()='Record Payment (Check, Cash, EFT ...)']"); |
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'); | |
86 | $this->waitForPageToLoad("30000"); | |
87 | $this->waitForText('crm-notification-container', "The contribution record has been saved."); | |
88 | ||
45fabf8e | 89 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
90 | $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a"); | |
b879962e | 91 | |
e9479dcf | 92 | //Check whether the next two payments are done or not |
45fabf8e | 93 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a[text()='View Payment']"); |
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 | |
e9479dcf | 97 | |
b879962e | 98 | //Cancel the contribution made for amount of 300.00 |
45fabf8e | 99 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a[text()='View Payment']"); |
100 | $this->click("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a"); | |
b879962e DG |
101 | $this->waitForElementPresent("xpath=//form[@id='ContributionView']//div[2]/div/div/a"); |
102 | $this->click("xpath=//form[@id='ContributionView']//div[2]/div/div/a"); | |
e9479dcf | 103 | $this->waitForElementPresent("_qf_Contribution_upload-bottom"); |
b879962e | 104 | $this->select('contribution_status_id', 'value=3'); |
e9479dcf | 105 | $this->click("_qf_Contribution_upload-bottom"); |
b879962e | 106 | |
45fabf8e | 107 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); |
108 | $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[1]/span/a"); | |
109 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[7]"); | |
e9479dcf | 110 | |
b879962e | 111 | // verify that first paayment is cancelled and the rest two payments are revert back to the pending status |
45fabf8e | 112 | $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[7]","Cancelled"); |
113 | $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[7]","Pending"); | |
114 | $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[4]/td[7]","Pending"); | |
b879962e DG |
115 | |
116 | // Check whether a new payment with pending status is added at the last or not | |
45fabf8e | 117 | $this->verifyText("xpath=//div[@class='view-content']//table/tbody/tr[2]/td[2]/table/tbody/tr[14]/td[7]","Pending"); |
b879962e DG |
118 | |
119 | // verify that Balance sum is correct | |
45fabf8e | 120 | $this->verifyText("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[4]","1,200.00"); |
b879962e DG |
121 | |
122 | } | |
123 | } | |
124 |