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