From b879962ead0e49849b821e7ad731b5ef7f1716fd Mon Sep 17 00:00:00 2001 From: Dave Greenberg Date: Mon, 1 Jul 2013 14:26:43 -0700 Subject: [PATCH] CRM-12271 webtest (new file) ---------------------------------------- * CRM-12271: Changing a contribution status from "completed" to "Cancelled" or "Refunded" breaks Pledge payments http://issues.civicrm.org/jira/browse/CRM-12271 --- .../WebTest/Pledge/AddCancelPaymentTest.php | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 tests/phpunit/WebTest/Pledge/AddCancelPaymentTest.php diff --git a/tests/phpunit/WebTest/Pledge/AddCancelPaymentTest.php b/tests/phpunit/WebTest/Pledge/AddCancelPaymentTest.php new file mode 100644 index 0000000000..f2f001f431 --- /dev/null +++ b/tests/phpunit/WebTest/Pledge/AddCancelPaymentTest.php @@ -0,0 +1,120 @@ +webtestLogin(); + + $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload'); + + // create new contact using dialog + $firstName = 'Ma' . substr(sha1(rand()), 0, 4); + $lastName = 'Za' . substr(sha1(rand()), 0, 7); + $this->webtestNewDialogContact($firstName, $lastName, $firstName . '@example.com'); + + $this->type('amount', '1200'); + $this->type('installments', '12'); + $this->select('frequency_unit', 'value=month'); + $this->type('frequency_day', '1'); + $this->webtestFillDate('acknowledge_date', 'now'); + $this->select('contribution_page_id', 'value=3'); + $this->click('_qf_Pledge_upload-bottom'); + $this->waitForPageToLoad("30000"); + + $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); + + // verify if Pledge is created + $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); + + //click through to the Pledge view screen + $this->click("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); + $this->waitForElementPresent('_qf_PledgeView_next-bottom'); + $pledgeDate = date('F jS, Y', strtotime('now')); + + $this->webtestVerifyTabularData(array( + 'Pledge By' => $firstName . ' ' . $lastName, + 'Total Pledge Amount' => '$ 1,200.00', + 'To be paid in' => '12 installments of $ 100.00 every 1 month(s)', + 'Payments are due on the' => '1 day of the period', + 'Pledge Made' => $pledgeDate, + 'Financial Type' => 'Donation', + 'Pledge Status' => 'Pending', + ) + ); + $this->clickLink('_qf_PledgeView_next-bottom', "xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); + $this->click("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[1]/span/a"); + //Edit and add the first payment for 300.00 + $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody//tr//td/table/tbody/tr[2]/td[8]/a[text()='Record Payment (Check, Cash, EFT ...)']"); + $this->click("xpath=//div[@id='Pledges']//table//tbody//tr//td/table/tbody/tr[2]/td[8]/a"); + $this->waitForElementPresent("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a"); + $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a"); + $this->type('total_amount', '300.00'); + $this->click('_qf_Contribution_upload-bottom'); + $this->waitForPageToLoad("30000"); + $this->waitForText('crm-notification-container', "The contribution record has been saved."); + + $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); + $this->click("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[1]/span/a"); + + //Check whether the next two payments are done or not + $this->waitForElementPresent("xpath=//div[@id='Pledges']//table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a[text()='View Payment']"); + $this->verifyText("xpath=//div[@id='Pledges']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[7]","Completed"); + $this->verifyText("xpath=//div[@id='Pledges']//table/tbody/tr[2]/td[2]/table/tbody/tr[4]/td[7]","Completed"); + + + //Cancel the contribution made for amount of 300.00 + $this->waitForElementPresent("xpath=//div[@id='Pledges']//table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a[text()='View Payment']"); + $this->click("xpath=//div[@id='Pledges']//table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a"); + $this->waitForElementPresent("xpath=//form[@id='ContributionView']//div[2]/div/div/a"); + $this->click("xpath=//form[@id='ContributionView']//div[2]/div/div/a"); + $this->waitForElementPresent("_qf_Contribution_upload-bottom"); + $this->select('contribution_status_id', 'value=3'); + $this->click("_qf_Contribution_upload-bottom"); + + $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); + $this->click("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[1]/span/a"); + $this->waitForElementPresent("xpath=//div[@id='Pledges']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[7]"); + + // verify that first paayment is cancelled and the rest two payments are revert back to the pending status + $this->verifyText("xpath=//div[@id='Pledges']//table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[7]","Cancelled"); + $this->verifyText("xpath=//div[@id='Pledges']//table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[7]","Pending"); + $this->verifyText("xpath=//div[@id='Pledges']//table/tbody/tr[2]/td[2]/table/tbody/tr[4]/td[7]","Pending"); + + // Check whether a new payment with pending status is added at the last or not + $this->verifyText("xpath=//div[@id='Pledges']//table/tbody/tr[2]/td[2]/table/tbody/tr[14]/td[7]","Pending"); + + // verify that Balance sum is correct + $this->verifyText("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[4]","1,200.00"); + + } +} + -- 2.25.1