Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Contribute_OfflineRecurContributionTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testOfflineRecurContribution() { | |
6a488035 TO |
35 | $this->webtestLogin(); |
36 | ||
37 | // We need a payment processor | |
38 | $processorName = 'Webtest AuthNet' . substr(sha1(rand()), 0, 7); | |
39 | $this->webtestAddPaymentProcessor($processorName, 'AuthNet'); | |
40 | ||
41 | // create a new contact for whom recurring contribution is to be created | |
42 | $firstName = 'Jane' . substr(sha1(rand()), 0, 7); | |
43 | $middleName = 'Middle'; | |
44 | $lastName = 'Recuroff_' . substr(sha1(rand()), 0, 7); | |
45 | $this->webtestAddContact($firstName, $lastName, "{$firstName}@example.com"); | |
46 | $contactName = "$firstName $lastName"; | |
47 | ||
48 | $this->click('css=li#tab_contribute a'); | |
49 | ||
50 | $this->waitForElementPresent('link=Submit Credit Card Contribution'); | |
6a488035 | 51 | // since we don't have live credentials we will switch to test mode |
ff7319de | 52 | $url = $this->getAttribute("xpath=//*[@id='Search']//a[text()='Submit Credit Card Contribution']@href"); |
6a488035 TO |
53 | $url = str_replace('mode=live', 'mode=test', $url); |
54 | $this->open($url); | |
a471a3b6 | 55 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
6a488035 TO |
56 | |
57 | // start filling out contribution form | |
58 | $this->waitForElementPresent('payment_processor_id'); | |
59 | $this->select('payment_processor_id', "label={$processorName}"); | |
60 | ||
61 | $this->click('financial_type_id'); | |
62 | $this->select('financial_type_id', 'label=Donation'); | |
63 | $this->type('total_amount', '10'); | |
64 | ||
65 | // recurring contribution fields | |
66 | $this->click('is_recur'); | |
67 | $this->type('frequency_interval', '1'); | |
68 | $this->select('frequency_unit', 'label=month(s)'); | |
69 | $this->type('installments', '12'); | |
70 | ||
71 | $this->click('is_email_receipt'); | |
72 | $this->waitForElementPresent('credit_card_type'); | |
73 | ||
74 | // enter credit card info on form | |
75 | $this->webtestAddCreditCardDetails(); | |
76 | ||
77 | // billing address | |
78 | $this->webtestAddBillingDetails($firstName, $middleName, $lastName); | |
6a488035 | 79 | $this->click('_qf_Contribution_upload-bottom'); |
ff7319de | 80 | $this->waitForElementPresent('link=Edit'); |
81 | $this->waitForText('crm-notification-container', "The contribution record has been processed."); | |
6a488035 | 82 | // Use Find Contributions to make sure test recurring contribution exists |
42daf119 | 83 | $this->openCiviPage("contribute/search", "reset=1", 'contribution_currency_type'); |
6a488035 TO |
84 | |
85 | $this->type('sort_name', "$lastName, $firstName"); | |
86 | $this->click('contribution_test'); | |
87 | $this->click('_qf_Search_refresh'); | |
88 | ||
a1c7d42f CW |
89 | $this->waitForElementPresent('css=#contributionSearch table tbody tr td span a.action-item:first-child'); |
90 | $this->click('css=#contributionSearch table tbody tr td span a.action-item:first-child'); | |
6a488035 TO |
91 | $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); |
92 | ||
93 | // View Recurring Contribution Record | |
94 | $verifyData = array( | |
95 | 'From' => "$contactName", | |
96 | 'Financial Type' => 'Donation (test)', | |
97 | 'Total Amount' => 'Installments: 12, Interval: 1 month(s)', | |
98 | 'Contribution Status' => 'Pending : Incomplete Transaction', | |
99 | 'Paid By' => 'Credit Card', | |
100 | ); | |
76e86fd8 | 101 | |
6a488035 TO |
102 | foreach ($verifyData as $label => $value) { |
103 | $this->verifyText("xpath=//form[@id='ContributionView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
104 | preg_quote($value) | |
105 | ); | |
106 | } | |
107 | } | |
108 | } | |
109 |