3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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';
30 * Class WebTest_Member_OnlineAutoRenewMembershipGCTest
32 class WebTest_Member_OnlineAutoRenewMembershipGCTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testOnlineAutoRenewMembershipAnonymous() {
39 //configure membership signup page.
40 $pageId = $this->_configureMembershipPage();
42 //now do the test membership signup.
43 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
45 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
46 $this->click("auto_renew");
49 $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
50 $this->type('email-5', "{$lastName}@example.com");
52 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next_checkout");
54 $text = 'I want this membership to be renewed automatically every 1 year(s).';
55 $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text);
57 $this->click("_qf_Confirm_next_checkout");
58 // Because it tends to cause problems, all uses of sleep() must be justified in comments
59 // Sleep should never be used for wait for anything to load from the server
60 // Justification for this instance: FIXME
63 // FIXME: By this time pending records has already been created. Formatting for external page (google checkout in this case)
65 // has changed a bit. No point in adding test for external page as we 'll test with fake transactions.
68 public function testOnlineAutoRenewMembershipAuthenticated() {
69 //configure membership signup page.
70 $pageId = $this->_configureMembershipPage();
72 $this->webtestLogin();
73 $this->waitForPageToLoad($this->getTimeoutMsec());
75 //now do the test membership signup.
76 $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom");
77 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]/div[2]/span/label/span[1][contains(text(),'Student')]");
79 $this->click("auto_renew");
82 $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
83 $this->type('email-5', "{$lastName}@example.com");
85 $this->clickLink("_qf_Main_upload-bottom", "_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)
98 // has changed a bit. No point in adding test for external page as we 'll test with fake transactions.
104 public function _configureMembershipPage() {
105 static $pageId = NULL;
108 $this->webtestLogin();
110 //add payment processor.
111 $hash = substr(sha1(rand()), 0, 7);
112 $rand = 2 * rand(2, 50);
113 $processorName = "Webtest Auto Renew Google Checkout" . $hash;
114 $this->webtestAddPaymentProcessor($processorName, 'Google_Checkout');
116 // -- start updating membership types
117 $this->openCiviPage('admin/member/membershipType/add', 'action=update&id=1&reset=1');
119 $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')]");
120 $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')]");
122 $this->type("duration_interval", "1");
123 $this->select("duration_unit", "label=year");
125 $this->click("_qf_MembershipType_upload-bottom");
126 $this->waitForPageToLoad($this->getTimeoutMsec());
128 $this->openCiviPage('admin/member/membershipType/add', 'action=update&id=2&reset=1');
130 $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')]");
131 $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')]");
133 $this->type("duration_interval", "1");
134 $this->select("duration_unit", "label=year");
136 $this->click("_qf_MembershipType_upload-bottom");
137 $this->waitForPageToLoad($this->getTimeoutMsec());
139 // create contribution page with randomized title and default params
140 $amountSection = FALSE;
145 $membershipTypes = array(
146 array('id' => 1, 'auto_renew' => 1),
147 array('id' => 2, 'auto_renew' => 1),
149 $memPriceSetId = NULL;
151 $profilePreId = NULL;
152 $profilePostId = NULL;
157 $contributionTitle = "Title $hash";
158 $pageId = $this->webtestAddContributionPage($hash,
161 array($processorName => 'Google_Checkout'),
178 //make sure we do have required permissions.
179 $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms");
180 $this->changePermissions($permissions);
182 // now logout and do membership test that way
183 $this->webtestLogout();