3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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_ContactContextAddTest
32 class WebTest_Member_ContactContextAddTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testContactMemberAdd() {
39 $this->webtestLogin();
41 // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
42 $memTypeParams = $this->webtestAddMembershipType();
43 $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime');
45 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
47 $firstName = "John_" . substr(sha1(rand()), 0, 7);
50 $this->type("first_name", $firstName);
53 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);
54 $this->type("last_name", $lastName);
57 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
58 $this->type("email_1_email", $email);
61 $this->click("_qf_Contact_upload_view");
62 $this->waitForPageToLoad($this->getTimeoutMsec());
63 $this->waitForText('crm-notification-container', "$firstName $lastName");
65 // click through to the membership view screen
66 $this->click("css=li#tab_member a");
68 $this->waitForElementPresent("link=Add Membership");
69 $this->click("link=Add Membership");
71 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
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 // Because it tends to cause problems, all uses of sleep() must be justified in comments
78 // Sleep should never be used for wait for anything to load from the server
79 // Justification for this instance: FIXME
81 $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}");
83 $sourceText = "Membership ContactAddTest Webtest";
85 $this->type("source", $sourceText);
87 // Let Join Date stay default
90 $this->webtestFillDate('start_date');
93 $this->click("_qf_Membership_upload");
96 $this->waitForTextPresent($sourceText);
98 // Is status message correct?
99 $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added.");
101 // click through to the membership view screen
102 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
103 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
106 'Membership Type' => $memTypeParams['membership_type'],
108 'Source' => $sourceText,
110 $this->webtestVerifyTabularData($verifyData);
112 $this->click("_qf_MembershipView_cancel-bottom");
114 $this->waitForTextPresent($sourceText);
116 $this->waitForElementPresent("css=li#tab_activity a");
117 // click through to the activities screen
118 $this->click("css=li#tab_activity a");
120 $this->waitForTextPresent('Membership Signup');
122 // click through to the activiy view screen (which is the membership view
123 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
124 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
127 'Membership Type' => $memTypeParams['membership_type'],
129 'Source' => $sourceText,
131 $this->webtestVerifyTabularData($verifyData);
132 $this->clickLink("_qf_MembershipView_cancel-bottom", "xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[7]", FALSE);
133 $this->click("xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[9]/span/a[2][text()='Edit']");
134 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
136 // fill in Membership Organization and Type
137 $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}");
138 // Wait for membership type select to reload
139 $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']);
140 $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}");
142 $this->waitForElementPresent("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]");
143 $this->click("xpath=//form[@id='Membership']/div[2]/div[2]/table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]/a");
145 $this->click("_qf_Membership_upload-bottom");
147 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
149 $this->waitForTextPresent($sourceText);
150 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
151 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
155 'Source' => $sourceText,
158 $this->webtestVerifyTabularData($verifyData);
161 public function testMemberAddWithLifeTimeMembershipType() {
162 $this->webtestLogin();
164 // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
165 $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime');
167 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
169 $firstName = "John_" . substr(sha1(rand()), 0, 7);
172 $this->type("first_name", $firstName);
175 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
176 $this->type("last_name", $lastName);
179 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
180 $this->type("email_1_email", $email);
183 $this->click("_qf_Contact_upload_view");
184 $this->waitForPageToLoad($this->getTimeoutMsec());
185 $this->waitForText('crm-notification-container', "$firstName $lastName has been created.");
187 // click through to the membership view screen
188 $this->click("css=li#tab_member a");
190 $this->waitForElementPresent("link=Add Membership");
191 $this->click("link=Add Membership");
193 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
195 // fill in Membership Organization and Type
196 $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}");
198 // Wait for membership type select to reload
199 $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']);
200 // Because it tends to cause problems, all uses of sleep() must be justified in comments
201 // Sleep should never be used for wait for anything to load from the server
202 // Justification for this instance: FIXME
204 $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}");
206 $sourceText = "Check Lifetime membership type webtest";
208 $this->type("source", $sourceText);
210 // Let Join Date stay default
212 // fill in Start Date
213 $this->webtestFillDate('start_date');
216 $this->click("_qf_Membership_upload");
219 $this->waitForTextPresent($sourceText);
221 // Is status message correct?
222 $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added.");
224 // click through to the membership view screen
225 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
226 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
230 'Source' => $sourceText,
233 $this->webtestVerifyTabularData($verifyData);
234 $this->click("_qf_MembershipView_cancel-bottom");
235 $this->waitForElementPresent("mainTabContainer");