Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | |
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 | |
d2771e94 | 66 | $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); |
6a488035 | 67 | |
6a488035 TO |
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 | ||
6a488035 TO |
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"); | |
6a488035 | 85 | |
6c5f7368 | 86 | $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); |
6a488035 | 87 | |
45fabf8e | 88 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']"); |
6a488035 | 89 | //click through to the Pledge view screen |
45fabf8e | 90 | $this->click("xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']"); |
6a488035 TO |
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', | |
6a488035 TO |
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 | ||
45fabf8e | 111 | $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']", FALSE); |
48b420d7 | 112 | |
169535ea | 113 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a"); |
45fabf8e | 114 | $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a"); |
169535ea | 115 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody//tr//td[2]/table/tbody/tr[2]/td[8]/a[text()='Record Payment']"); |
400ed621 DG |
116 | // Re-enable pop-ups to leave things in the same state |
117 | $this->enableDisablePopups(TRUE); | |
6a488035 | 118 | } |
96025800 | 119 | |
6a488035 | 120 | } |