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