Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Pledge_ContactContextAddTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testContactContextAddTest() { |
6a488035 | 39 | $this->webtestLogin(); |
400ed621 DG |
40 | // Disable pop-ups for this test. Running test w/ pop-ups causes a spurious failure. dgg |
41 | $this->enableDisablePopups(FALSE); | |
6a488035 TO |
42 | |
43 | // create unique name | |
92915c55 | 44 | $name = substr(sha1(rand()), 0, 7); |
6a488035 | 45 | $firstName = 'Adam' . $name; |
92915c55 | 46 | $lastName = 'Jones' . $name; |
6a488035 TO |
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 | |
952cc48f WA |
55 | $this->click("xpath=//div[@class='crm-actions-ribbon']/ul[@id='actions']/li[@class='crm-contact-activity crm-summary-block']/div/a[@id='crm-contact-actions-link']"); |
56 | $this->waitForElementPresent('crm-contact-actions-list'); | |
6a488035 TO |
57 | |
58 | // wait for add plegde link | |
59 | $this->waitForElementPresent('link=Add Pledge'); | |
60 | ||
61 | $this->click('link=Add Pledge'); | |
62 | ||
63 | // wait for pledge form to load completely | |
64 | $this->waitForElementPresent('_qf_Pledge_upload-bottom'); | |
65 | ||
66 | // check contact name on pledge form | |
d2771e94 | 67 | $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); |
6a488035 | 68 | |
6a488035 TO |
69 | $this->type("amount", "100"); |
70 | $this->type("installments", "10"); | |
71 | $this->select("frequency_unit", "value=week"); | |
72 | $this->type("frequency_day", "2"); | |
73 | ||
74 | $this->webtestFillDate('acknowledge_date', 'now'); | |
75 | ||
76 | $this->select("contribution_page_id", "value=3"); | |
77 | ||
6a488035 TO |
78 | //PaymentReminders |
79 | $this->click("PaymentReminders"); | |
80 | $this->waitForElementPresent("additional_reminder_day"); | |
81 | $this->type("initial_reminder_day", "4"); | |
82 | $this->type("max_reminders", "2"); | |
83 | $this->type("additional_reminder_day", "4"); | |
84 | ||
85 | $this->click("_qf_Pledge_upload-bottom"); | |
6a488035 | 86 | |
6c5f7368 | 87 | $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); |
6a488035 | 88 | |
45fabf8e | 89 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']"); |
6a488035 | 90 | //click through to the Pledge view screen |
45fabf8e | 91 | $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']"); |
6a488035 TO |
92 | $this->waitForElementPresent("_qf_PledgeView_next-bottom"); |
93 | $pledgeDate = date('F jS, Y', strtotime('now')); | |
94 | ||
95 | $verifyData = array( | |
96 | 'Pledge By' => $firstName . ' ' . $lastName, | |
97 | 'Total Pledge Amount' => '$ 100.00', | |
98 | 'To be paid in' => '10 installments of $ 10.00 every 1 week(s)', | |
99 | 'Payments are due on the' => '2 day of the period', | |
100 | 'Pledge Made' => $pledgeDate, | |
101 | 'Financial Type' => 'Donation', | |
102 | 'Pledge Status' => 'Pending', | |
6a488035 TO |
103 | 'Initial Reminder Day' => '4 days prior to schedule date', |
104 | 'Maximum Reminders Send' => 2, | |
105 | 'Send additional reminders' => '4 days after the last one sent', | |
106 | ); | |
107 | ||
108 | foreach ($verifyData as $label => $value) { | |
109 | $this->verifyText("xpath=//form[@id='PledgeView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value)); | |
110 | } | |
111 | ||
b9fdba0a | 112 | $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div/table/tbody/tr[1]/td[10]/span[1]/a[text()='View']", FALSE); |
48b420d7 | 113 | |
a2046f62 SB |
114 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a"); |
115 | $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/a"); | |
116 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody//tr//td/div/table/tbody/tr[2]/td[8]/a[text()='Record Payment']"); | |
400ed621 DG |
117 | // Re-enable pop-ups to leave things in the same state |
118 | $this->enableDisablePopups(TRUE); | |
6a488035 | 119 | } |
96025800 | 120 | |
6a488035 | 121 | } |