Commit | Line | Data |
---|---|---|
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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Contribute_ConfirmOptionalTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contribute_ConfirmOptionalTest extends CiviSeleniumTestCase { |
33 | protected $pageId = 0; | |
34 | ||
35 | protected function setUp() { | |
36 | parent::setUp(); | |
37 | } | |
38 | ||
00be9182 | 39 | public function testWithConfirm() { |
6a488035 TO |
40 | $this->_addContributionPage(TRUE); |
41 | $this->_fillOutContributionPage(); | |
42 | ||
43 | // confirm contribution | |
44 | $this->assertFalse($this->isTextPresent("Your transaction has been processed successfully"), "Loaded thank you page"); | |
45 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
46 | $this->assertTrue($this->isTextPresent("Please verify the information below carefully"), "Should load confirmation page"); | |
47 | $this->click("_qf_Confirm_next-bottom"); | |
48 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
49 | ||
50 | // thank you page | |
51 | $this->assertTrue($this->isTextPresent("Your transaction has been processed successfully"), "Should load thank you page"); | |
52 | } | |
53 | ||
00be9182 | 54 | public function testWithoutConfirm() { |
6a488035 TO |
55 | $this->_addContributionPage(FALSE); |
56 | $this->_fillOutContributionPage(); | |
57 | ||
58 | // thank you page | |
59 | $this->assertTrue($this->isTextPresent("Your transaction has been processed successfully"), "Didn't load thank you page after main page"); | |
60 | $this->assertFalse($this->isTextPresent("Your contribution will not be completed until"), "Loaded confirmation page"); | |
61 | } | |
62 | ||
4cbe18b8 EM |
63 | /** |
64 | * @param $isConfirmEnabled | |
65 | */ | |
6a488035 TO |
66 | protected function _addContributionPage($isConfirmEnabled) { |
67 | // log in | |
6a488035 TO |
68 | $this->webtestLogin(); |
69 | ||
70 | // create new contribution page | |
71 | $hash = substr(sha1(rand()), 0, 7); | |
72 | $this->pageId = $this->webtestAddContributionPage( | |
73 | $hash, | |
74 | $rand = NULL, | |
75 | $pageTitle = "Test Confirm ($hash)", | |
76 | $processor = array("Dummy ($hash)" => 'Dummy'), | |
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, | |
91d49cae | 94 | $allowOtherAmount = TRUE, |
6a488035 TO |
95 | $isConfirmEnabled = $isConfirmEnabled |
96 | ); | |
97 | } | |
98 | ||
99 | protected function _fillOutContributionPage() { | |
100 | // load contribution page | |
42daf119 | 101 | $this->openCiviPage("contribute/transact", "reset=1&id={$this->pageId}", "_qf_Main_upload-bottom"); |
6a488035 TO |
102 | |
103 | // fill out info | |
104 | $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", "30"); | |
105 | $this->webtestAddCreditCardDetails(); | |
106 | list($firstName, $middleName, $lastName) = $this->webtestAddBillingDetails(); | |
107 | $this->type('email-5', "$lastName@example.com"); | |
108 | ||
109 | // submit contribution | |
110 | $this->click("_qf_Main_upload-bottom"); | |
111 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
112 | } | |
96025800 | 113 | |
6a488035 | 114 | } |