Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
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_Contribute_VerifySSLContributionTest | |
31 | */ | |
6a488035 TO |
32 | class 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)"; | |
6a488035 TO |
63 | //$this->names['PayPal_Standard'] = "PayPal Standard ($hash)"; |
64 | ||
65 | $processors = array(); | |
66 | foreach ($this->names as $key => $val) { | |
67 | $processors[$val] = $key; | |
68 | } | |
69 | ||
70 | // create new contribution page | |
71 | $this->pageId = $this->webtestAddContributionPage( | |
72 | $hash, | |
73 | $rand = NULL, | |
74 | $pageTitle = $contributionPageTitle, | |
75 | $processor = $processors, | |
76 | $amountSection = TRUE, | |
77 | $payLater = FALSE, | |
78 | $onBehalf = FALSE, | |
79 | $pledges = FALSE, | |
80 | $recurring = FALSE, | |
81 | $membershipTypes = FALSE, | |
82 | $memPriceSetId = NULL, | |
83 | $friend = FALSE, | |
84 | $profilePreId = NULL, | |
85 | $profilePostId = NULL, | |
86 | $premiums = FALSE, | |
87 | $widget = FALSE, | |
88 | $pcp = FALSE, | |
89 | $isAddPaymentProcessor = TRUE, | |
90 | $isPcpApprovalNeeded = FALSE, | |
91 | $isSeparatePayment = FALSE, | |
92 | $honoreeSection = FALSE, | |
10525e44 | 93 | $allowOtherAmount = TRUE |
6a488035 TO |
94 | ); |
95 | ||
96 | // enable verify ssl | |
071a6d2e | 97 | $this->openCiviPage("admin/setting/url", "reset=1"); |
6a488035 TO |
98 | $this->click("id=CIVICRM_QFID_1_verifySSL"); |
99 | $this->click("id=_qf_Url_next-bottom"); | |
100 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
101 | ||
102 | $this->initialized = TRUE; | |
103 | } | |
104 | } | |
105 | ||
4cbe18b8 | 106 | /** |
100fef9d | 107 | * @param string $name |
4cbe18b8 | 108 | */ |
00be9182 | 109 | public function _tryPaymentProcessor($name) { |
6a488035 | 110 | // load contribution page |
42daf119 | 111 | $this->openCiviPage("contribute/transact", "reset=1&action=preview&id={$this->pageId}", "_qf_Main_upload-bottom"); |
6a488035 TO |
112 | |
113 | // fill out info | |
114 | $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", "30"); | |
115 | $this->type('email-5', "smith@example.com"); | |
116 | ||
117 | // choose the payment processor | |
118 | $this->click("xpath=//label[text() = '{$name}']/preceding-sibling::input[1]"); | |
119 | ||
120 | // do we need to add credit card details? | |
121 | if (strpos($name, "AuthNet") !== FALSE || strpos($name, "PayPal Pro") !== FALSE) { | |
122 | $this->webtestAddCreditCardDetails(); | |
123 | list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails(); | |
124 | } | |
125 | ||
126 | // submit contribution | |
225a8648 | 127 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
128 | |
129 | // confirm contribution | |
130 | $this->click("_qf_Confirm_next-bottom"); | |
131 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a63c43ee | 132 | $this->assertStringsPresent("Payment Processor Error message"); |
6a488035 | 133 | } |
96025800 | 134 | |
6a488035 | 135 | } |