3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Member_OnlineAutoRenewMembershipGCTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testOnlineAutoRenewMembershipAnonymous() {
35 //configure membership signup page.
36 $pageId = $this->_configureMembershipPage();
38 //now do the test membership signup.
39 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
41 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
42 $this->click("auto_renew");
45 $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
46 $this->type('email-5', "{$lastName}@example.com");
48 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next_checkout");
50 $text = 'I want this membership to be renewed automatically every 1 year(s).';
51 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
53 $this->click("_qf_Confirm_next_checkout");
54 // Because it tends to cause problems, all uses of sleep() must be justified in comments
55 // Sleep should never be used for wait for anything to load from the server
56 // Justification for this instance: FIXME
59 // FIXME: By this time pending records has already been created. Formatting for external page (google checkout in this case)
61 // has changed a bit. No point in adding test for external page as we 'll test with fake transactions.
64 function testOnlineAutoRenewMembershipAuthenticated() {
65 //configure membership signup page.
66 $pageId = $this->_configureMembershipPage();
68 $this->webtestLogin();
69 $this->waitForPageToLoad($this->getTimeoutMsec());
71 //now do the test membership signup.
72 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
73 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]");
75 $this->click("auto_renew");
78 $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
79 $this->type('email-5', "{$lastName}@example.com");
81 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next_checkout");
83 $text = 'I want this membership to be renewed automatically every 1 year(s).';
84 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
86 $this->click("_qf_Confirm_next_checkout");
87 // Because it tends to cause problems, all uses of sleep() must be justified in comments
88 // Sleep should never be used for wait for anything to load from the server
89 // Justification for this instance: FIXME
92 // FIXME: By this time pending records has already been created. Formatting for external page (google checkout in this case)
94 // has changed a bit. No point in adding test for external page as we 'll test with fake transactions.
97 function _configureMembershipPage() {
98 static $pageId = NULL;
101 $this->webtestLogin();
103 //add payment processor.
104 $hash = substr(sha1(rand()), 0, 7);
105 $rand = 2 * rand(2, 50);
106 $processorName = "Webtest Auto Renew Google Checkout" . $hash;
107 $this->webtestAddPaymentProcessor($processorName, 'Google_Checkout');
109 // -- start updating membership types
110 $this->openCiviPage('admin/member/membershipType/add', 'action=update&id=1&reset=1');
112 $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')]");
113 $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')]");
115 $this->type("duration_interval", "1");
116 $this->select("duration_unit", "label=year");
118 //wait for the auto-complete member_of_contact to populate
119 $this->waitForValue('member_of_contact', '::');
121 $this->click("_qf_MembershipType_upload-bottom");
122 $this->waitForPageToLoad($this->getTimeoutMsec());
124 $this->openCiviPage('admin/member/membershipType/add', 'action=update&id=2&reset=1');
126 $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')]");
127 $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')]");
129 $this->type("duration_interval", "1");
130 $this->select("duration_unit", "label=year");
132 //wait for the auto-complete member_of_contact to populate
133 $this->waitForValue('member_of_contact', '::');
135 $this->click("_qf_MembershipType_upload-bottom");
136 $this->waitForPageToLoad($this->getTimeoutMsec());
138 // create contribution page with randomized title and default params
139 $amountSection = FALSE;
144 $membershipTypes = array(array('id' => 1, 'auto_renew' => 1),
145 array('id' => 2, 'auto_renew' => 1),
147 $memPriceSetId = NULL;
149 $profilePreId = NULL;
150 $profilePostId = NULL;
155 $contributionTitle = "Title $hash";
156 $pageId = $this->webtestAddContributionPage($hash,
159 array($processorName => 'Google_Checkout'),
176 //make sure we do have required permissions.
177 $permissions = array("edit-1-make-online-contributions");
178 $this->changePermissions($permissions);
180 // now logout and do membership test that way
181 $this->webtestLogout();