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