Start migrating to use clickLink method
[civicrm-core.git] / tests / phpunit / WebTest / Contribute / ConfirmOptionalTest.php
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
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contribute_ConfirmOptionalTest extends CiviSeleniumTestCase {
30 protected $pageId = 0;
31
32 protected function setUp() {
33 parent::setUp();
34 }
35
36 function testWithConfirm() {
37 $this->_addContributionPage(TRUE);
38 $this->_fillOutContributionPage();
39
40 // confirm contribution
41 $this->assertFalse($this->isTextPresent("Your transaction has been processed successfully"), "Loaded thank you page");
42 $this->waitForElementPresent("_qf_Confirm_next-bottom");
43 $this->assertTrue($this->isTextPresent("Please verify the information below carefully"), "Should load confirmation page");
44 $this->click("_qf_Confirm_next-bottom");
45 $this->waitForPageToLoad($this->getTimeoutMsec());
46
47 // thank you page
48 $this->assertTrue($this->isTextPresent("Your transaction has been processed successfully"), "Should load thank you page");
49 }
50
51 function testWithoutConfirm() {
52 $this->_addContributionPage(FALSE);
53 $this->_fillOutContributionPage();
54
55 // thank you page
56 $this->assertTrue($this->isTextPresent("Your transaction has been processed successfully"), "Didn't load thank you page after main page");
57 $this->assertFalse($this->isTextPresent("Your contribution will not be completed until"), "Loaded confirmation page");
58 }
59
60 protected function _addContributionPage($isConfirmEnabled) {
61 // log in
62 $this->webtestLogin();
63
64 // create new contribution page
65 $hash = substr(sha1(rand()), 0, 7);
66 $this->pageId = $this->webtestAddContributionPage(
67 $hash,
68 $rand = NULL,
69 $pageTitle = "Test Confirm ($hash)",
70 $processor = array("Dummy ($hash)" => 'Dummy'),
71 $amountSection = TRUE,
72 $payLater = FALSE,
73 $onBehalf = FALSE,
74 $pledges = FALSE,
75 $recurring = FALSE,
76 $membershipTypes = FALSE,
77 $memPriceSetId = NULL,
78 $friend = FALSE,
79 $profilePreId = NULL,
80 $profilePostId = NULL,
81 $premiums = FALSE,
82 $widget = FALSE,
83 $pcp = FALSE,
84 $isAddPaymentProcessor = TRUE,
85 $isPcpApprovalNeeded = FALSE,
86 $isSeparatePayment = FALSE,
87 $honoreeSection = FALSE,
88 $allowOtherAmmount = TRUE,
89 $isConfirmEnabled = $isConfirmEnabled
90 );
91 }
92
93 protected function _fillOutContributionPage() {
94 // load contribution page
95 $this->openCiviPage("contribute/transact", "reset=1&id={$this->pageId}", "_qf_Main_upload-bottom");
96
97 // fill out info
98 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", "30");
99 $this->webtestAddCreditCardDetails();
100 list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails();
101 $this->type('email-5', "$lastName@example.com");
102
103 // submit contribution
104 $this->click("_qf_Main_upload-bottom");
105 $this->waitForPageToLoad($this->getTimeoutMsec());
106 }
107 }
108