| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
| 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'; |
| 28 | |
| 29 | /** |
| 30 | * Class WebTest_Pledge_ContactContextAddTest |
| 31 | */ |
| 32 | class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase { |
| 33 | |
| 34 | protected function setUp() { |
| 35 | parent::setUp(); |
| 36 | } |
| 37 | |
| 38 | public function testContactContextAddTest() { |
| 39 | $this->webtestLogin(); |
| 40 | // Disable pop-ups for this test. Running test w/ pop-ups causes a spurious failure. dgg |
| 41 | $this->enableDisablePopups(FALSE); |
| 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 |
| 66 | $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); |
| 67 | |
| 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 | |
| 77 | //PaymentReminders |
| 78 | $this->click("PaymentReminders"); |
| 79 | $this->waitForElementPresent("additional_reminder_day"); |
| 80 | $this->type("initial_reminder_day", "4"); |
| 81 | $this->type("max_reminders", "2"); |
| 82 | $this->type("additional_reminder_day", "4"); |
| 83 | |
| 84 | $this->click("_qf_Pledge_upload-bottom"); |
| 85 | |
| 86 | $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); |
| 87 | |
| 88 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']"); |
| 89 | //click through to the Pledge view screen |
| 90 | $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']"); |
| 91 | $this->waitForElementPresent("_qf_PledgeView_next-bottom"); |
| 92 | $pledgeDate = date('F jS, Y', strtotime('now')); |
| 93 | |
| 94 | $verifyData = array( |
| 95 | 'Pledge By' => $firstName . ' ' . $lastName, |
| 96 | 'Total Pledge Amount' => '$ 100.00', |
| 97 | 'To be paid in' => '10 installments of $ 10.00 every 1 week(s)', |
| 98 | 'Payments are due on the' => '2 day of the period', |
| 99 | 'Pledge Made' => $pledgeDate, |
| 100 | 'Financial Type' => 'Donation', |
| 101 | 'Pledge Status' => 'Pending', |
| 102 | 'Initial Reminder Day' => '4 days prior to schedule date', |
| 103 | 'Maximum Reminders Send' => 2, |
| 104 | 'Send additional reminders' => '4 days after the last one sent', |
| 105 | ); |
| 106 | |
| 107 | foreach ($verifyData as $label => $value) { |
| 108 | $this->verifyText("xpath=//form[@id='PledgeView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value)); |
| 109 | } |
| 110 | |
| 111 | $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']", FALSE); |
| 112 | |
| 113 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a"); |
| 114 | $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a"); |
| 115 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody//tr//td[2]/table/tbody/tr[2]/td[8]/a[text()='Record Payment']"); |
| 116 | // Re-enable pop-ups to leave things in the same state |
| 117 | $this->enableDisablePopups(TRUE); |
| 118 | } |
| 119 | |
| 120 | } |