Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Member_OfflineAutoRenewMembershipTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Member_OfflineAutoRenewMembershipTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | function testOfflineAutoRenewMembership() { | |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | ||
41 | // We need a payment processor | |
42 | $processorName = "Webtest AuthNet" . substr(sha1(rand()), 0, 7); | |
43 | $this->webtestAddPaymentProcessor($processorName, 'AuthNet'); | |
44 | ||
45 | // Create a membership type to use for this test | |
46 | $periodType = 'rolling'; | |
47 | $duration_interval = 1; | |
48 | $duration_unit = 'year'; | |
49 | $auto_renew = "optional"; | |
50 | ||
51 | $memTypeParams = $this->webtestAddMembershipType($periodType, $duration_interval, $duration_unit, $auto_renew); | |
52 | ||
53 | // create a new contact for whom membership is to be created | |
54 | $firstName = 'Apt' . substr(sha1(rand()), 0, 4); | |
55 | $lastName = 'Mem' . substr(sha1(rand()), 0, 7); | |
56 | $this->webtestAddContact($firstName, $lastName, "{$firstName}@example.com"); | |
57 | $contactName = "$firstName $lastName"; | |
58 | ||
59 | $this->click('css=li#tab_member a'); | |
60 | ||
61 | $this->waitForElementPresent('link=Submit Credit Card Membership'); | |
6a488035 TO |
62 | |
63 | // since we don't have live credentials we will switch to test mode | |
673c7418 | 64 | $url = $this->getAttribute("xpath=//div[@class='view-content']//div[@class='action-link']/a[2]@href"); |
6a488035 TO |
65 | $url = str_replace('mode=live', 'mode=test', $url); |
66 | $this->open($url); | |
a471a3b6 | 67 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
6a488035 TO |
68 | |
69 | // start filling membership form | |
70 | $this->waitForElementPresent('payment_processor_id'); | |
71 | $this->select("payment_processor_id", "label={$processorName}"); | |
72 | ||
73 | // fill in Membership Organization and Type | |
74 | $this->select("membership_type_id[0]", "label={$memTypeParams['member_of_contact']}"); | |
75 | // Wait for membership type select to reload | |
76 | $this->waitForTextPresent($memTypeParams['membership_type']); | |
77 | $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}"); | |
78 | ||
79 | $this->click("source"); | |
80 | $this->type("source", "Online Membership: Admin Interface"); | |
81 | ||
82 | $this->waitForElementPresent('auto_renew'); | |
83 | $this->click("auto_renew"); | |
84 | ||
85 | $this->webtestAddCreditCardDetails(); | |
86 | ||
6a488035 TO |
87 | $this->webtestAddBillingDetails($firstName, NULL, $lastName); |
88 | ||
b3d40287 | 89 | $this->clickLink("_qf_Membership_upload-bottom"); |
6a488035 TO |
90 | |
91 | // Use Find Members to make sure membership exists | |
42daf119 | 92 | $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); |
6a488035 TO |
93 | |
94 | $this->type("sort_name", "$firstName $lastName"); | |
95 | $this->click("member_test"); | |
225a8648 | 96 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr[1]/td[11]/span/a[text()='View']"); |
b3d40287 | 97 | $this->clickAjaxLink("xpath=//div[@id='memberSearch']/table/tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom"); |
6a488035 TO |
98 | |
99 | // View Membership Record | |
100 | $verifyData = array( | |
101 | 'Member' => "$firstName $lastName", | |
102 | 'Membership Type' => $memTypeParams['membership_type'], | |
103 | 'Source' => 'Online Membership: Admin Interface', | |
104 | 'Status' => 'Pending', | |
105 | 'Auto-renew' => 'Yes', | |
106 | ); | |
107 | foreach ($verifyData as $label => $value) { | |
108 | $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", | |
109 | preg_quote($value) | |
110 | ); | |
111 | } | |
6a488035 TO |
112 | } |
113 | } | |
114 |