Mass switch to openCiviPage method
[civicrm-core.git] / tests / phpunit / WebTest / Contribute / VerifySSLContributionTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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
28require_once 'CiviTest/CiviSeleniumTestCase.php';
29class WebTest_Contribute_VerifySSLContributionTest extends CiviSeleniumTestCase {
30
31 protected $initialized = FALSE;
32 protected $names = array();
33 protected $pageId = 0;
34
35 protected function setUp() {
36 parent::setUp();
37 }
38
39 function testPaymentProcessorsSSL() {
40 $this->_initialize();
41 $this->_tryPaymentProcessor($this->names['AuthNet']);
42
43 // todo: write code to check other payment processors
44 /*$this->_tryPaymentProcessor($this->names['Google_Checkout']);
45 $this->_tryPaymentProcessor($this->names['PayPal']);
46 $this->_tryPaymentProcessor($this->names['PayPal_Standard']);*/
47 }
48
49 function _initialize() {
50 if (!$this->initialized) {
51 // log in
42daf119 52 $this->webtestLogin();
6a488035
TO
53
54 // build names
55 $hash = substr(sha1(rand()), 0, 7);
56 $contributionPageTitle = "Verify SSL ($hash)";
57 $this->names['PayPal'] = "PayPal Pro ($hash)";
58 $this->names['AuthNet'] = "AuthNet ($hash)";
59 //$this->names['Google_Checkout'] = "Google Checkout ($hash)";
60 //$this->names['PayPal_Standard'] = "PayPal Standard ($hash)";
61
62 $processors = array();
63 foreach ($this->names as $key => $val) {
64 $processors[$val] = $key;
65 }
66
67 // create new contribution page
68 $this->pageId = $this->webtestAddContributionPage(
69 $hash,
70 $rand = NULL,
71 $pageTitle = $contributionPageTitle,
72 $processor = $processors,
73 $amountSection = TRUE,
74 $payLater = FALSE,
75 $onBehalf = FALSE,
76 $pledges = FALSE,
77 $recurring = FALSE,
78 $membershipTypes = FALSE,
79 $memPriceSetId = NULL,
80 $friend = FALSE,
81 $profilePreId = NULL,
82 $profilePostId = NULL,
83 $premiums = FALSE,
84 $widget = FALSE,
85 $pcp = FALSE,
86 $isAddPaymentProcessor = TRUE,
87 $isPcpApprovalNeeded = FALSE,
88 $isSeparatePayment = FALSE,
89 $honoreeSection = FALSE,
90 $allowOtherAmmount = TRUE
91 );
92
93 // enable verify ssl
071a6d2e 94 $this->openCiviPage("admin/setting/url", "reset=1");
6a488035
TO
95 $this->click("id=CIVICRM_QFID_1_verifySSL");
96 $this->click("id=_qf_Url_next-bottom");
97 $this->waitForPageToLoad($this->getTimeoutMsec());
98
99 $this->initialized = TRUE;
100 }
101 }
102
103 function _tryPaymentProcessor($name) {
104 // load contribution page
42daf119 105 $this->openCiviPage("contribute/transact", "reset=1&action=preview&id={$this->pageId}", "_qf_Main_upload-bottom");
6a488035
TO
106
107 // fill out info
108 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", "30");
109 $this->type('email-5', "smith@example.com");
110
111 // choose the payment processor
112 $this->click("xpath=//label[text() = '{$name}']/preceding-sibling::input[1]");
113
114 // do we need to add credit card details?
115 if (strpos($name, "AuthNet") !== FALSE || strpos($name, "PayPal Pro") !== FALSE) {
116 $this->webtestAddCreditCardDetails();
117 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
118 }
119
120 // submit contribution
121 $this->click("_qf_Main_upload-bottom");
122 $this->waitForPageToLoad($this->getTimeoutMsec());
123 $this->waitForElementPresent("_qf_Confirm_next-bottom");
124
125 // confirm contribution
126 $this->click("_qf_Confirm_next-bottom");
127 $this->waitForPageToLoad($this->getTimeoutMsec());
128 $this->assertFalse($this->isTextPresent("Payment Processor Error message"), "Payment processor returned error message");
129 }
130}
131