3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Member_OnlineAutoRenewMembershipGCTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testOnlineAutoRenewMembershipAnonymous() {
36 //configure membership signup page.
37 $pageId = $this->_configureMembershipPage();
39 //now do the test membership signup.
40 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
42 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
43 $this->click("auto_renew");
46 $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
47 $this->type('email-5', "{$lastName}@example.com");
49 $this->click("_qf_Main_upload-bottom");
50 $this->waitForPageToLoad($this->getTimeoutMsec());
51 $this->waitForElementPresent("_qf_Confirm_next_checkout");
53 $text = 'I want this membership to be renewed automatically every 1 year(s).';
54 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
56 $this->click("_qf_Confirm_next_checkout");
57 // Because it tends to cause problems, all uses of sleep() must be justified in comments
58 // Sleep should never be used for wait for anything to load from the server
59 // Justification for this instance: FIXME
62 // FIXME: By this time pending records has already been created. Formatting for external page (google checkout in this case)
63 // has changed a bit. No point in adding test for external page as we 'll test with fake transactions.
66 function testOnlineAutoRenewMembershipAuthenticated() {
67 //configure membership signup page.
68 $pageId = $this->_configureMembershipPage();
70 $this->webtestLogin();
71 $this->waitForPageToLoad($this->getTimeoutMsec());
73 //now do the test membership signup.
74 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
75 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
77 $this->click("auto_renew");
80 $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
81 $this->type('email-5', "{$lastName}@example.com");
83 $this->click("_qf_Main_upload-bottom");
84 $this->waitForPageToLoad($this->getTimeoutMsec());
85 $this->waitForElementPresent("_qf_Confirm_next_checkout");
87 $text = 'I want this membership to be renewed automatically every 1 year(s).';
88 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
90 $this->click("_qf_Confirm_next_checkout");
91 // Because it tends to cause problems, all uses of sleep() must be justified in comments
92 // Sleep should never be used for wait for anything to load from the server
93 // Justification for this instance: FIXME
96 // FIXME: By this time pending records has already been created. Formatting for external page (google checkout in this case)
97 // has changed a bit. No point in adding test for external page as we 'll test with fake transactions.
100 function _configureMembershipPage() {
101 static $pageId = NULL;
104 $this->webtestLogin();
106 //add payment processor.
107 $hash = substr(sha1(rand()), 0, 7);
108 $rand = 2 * rand(2, 50);
109 $processorName = "Webtest Auto Renew Google Checkout" . $hash;
110 $this->webtestAddPaymentProcessor($processorName, 'Google_Checkout');
112 // -- start updating membership types
113 $this->openCiviPage('admin/member/membershipType/add', 'action=update&id=1&reset=1');
115 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
116 $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
118 $this->type("duration_interval", "1");
119 $this->select("duration_unit", "label=year");
121 //wait for the auto-complete member_of_contact to populate
122 $this->waitForValue('member_of_contact', '::');
124 $this->click("_qf_MembershipType_upload-bottom");
125 $this->waitForPageToLoad($this->getTimeoutMsec());
127 $this->openCiviPage('admin/member/membershipType/add', 'action=update&id=2&reset=1');
129 $this->waitForElementPresent("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
130 $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]");
132 $this->type("duration_interval", "1");
133 $this->select("duration_unit", "label=year");
135 //wait for the auto-complete member_of_contact to populate
136 $this->waitForValue('member_of_contact', '::');
138 $this->click("_qf_MembershipType_upload-bottom");
139 $this->waitForPageToLoad($this->getTimeoutMsec());
141 // create contribution page with randomized title and default params
142 $amountSection = FALSE;
147 $membershipTypes = array(array('id' => 1, 'auto_renew' => 1),
148 array('id' => 2, 'auto_renew' => 1),
150 $memPriceSetId = NULL;
152 $profilePreId = NULL;
153 $profilePostId = NULL;
158 $contributionTitle = "Title $hash";
159 $pageId = $this->webtestAddContributionPage($hash,
162 array($processorName => 'Google_Checkout'),
179 //make sure we do have required permissions.
180 $permissions = array("edit-1-make-online-contributions");
181 $this->changePermissions($permissions);
183 // now logout and do membership test that way
184 $this->webtestLogout();