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_ContactContextAddTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testContactMemberAdd() {
36 $this->open($this->sboxPath
);
37 $this->webtestLogin();
39 // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
40 $memTypeParams = $this->webtestAddMembershipType();
41 $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime');
43 // Go directly to the URL of the screen that you will be testing (New Individual).
44 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
46 $firstName = "John_" . substr(sha1(rand()), 0, 7);
49 $this->type("first_name", $firstName);
52 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);
53 $this->type("last_name", $lastName);
56 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
57 $this->type("email_1_email", $email);
60 $this->click("_qf_Contact_upload_view");
61 $this->waitForPageToLoad($this->getTimeoutMsec());
62 $this->assertElementContainsText('crm-notification-container', "$firstName $lastName has been created.");
64 // click through to the membership view screen
65 $this->click("css=li#tab_member a");
67 $this->waitForElementPresent("link=Add Membership");
68 $this->click("link=Add Membership");
70 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
72 // fill in Membership Organization and Type
73 $this->select("membership_type_id[0]", "label={$memTypeParams['member_of_contact']}");
74 // Wait for membership type select to reload
75 $this->waitForTextPresent($memTypeParams['membership_type']);
77 $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}");
79 $sourceText = "Membership ContactAddTest Webtest";
81 $this->type("source", $sourceText);
83 // Let Join Date stay default
86 $this->webtestFillDate('start_date');
89 $this->click("_qf_Membership_upload");
90 $this->waitForPageToLoad($this->getTimeoutMsec());
93 $this->waitForTextPresent($sourceText);
95 // Is status message correct?
96 $this->assertElementContainsText('crm-notification-container', "membership for $firstName $lastName has been added.",
97 "Status message didn't show up after saving!");
99 // click through to the membership view screen
100 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
101 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
104 'Membership Type' => $memTypeParams['membership_type'],
106 'Source' => $sourceText,
108 $this->webtestVerifyTabularData($verifyData);
110 $this->click("_qf_MembershipView_cancel-bottom");
111 $this->waitForPageToLoad($this->getTimeoutMsec());
113 $this->waitForTextPresent($sourceText);
115 // click through to the activities screen
116 $this->click("css=li#tab_activity a");
118 $this->waitForTextPresent('Membership Signup');
120 // click through to the activiy view screen (which is the membership view
121 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
122 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
125 'Membership Type' => $memTypeParams['membership_type'],
127 'Source' => $sourceText,
129 $this->webtestVerifyTabularData($verifyData);
130 $this->click("_qf_MembershipView_cancel-bottom");
132 $this->waitForPageToLoad($this->getTimeoutMsec());
133 $this->waitForElementPresent("xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[7]");
134 $this->click("xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[9]/span/a[2][text()='Edit']");
135 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
137 // fill in Membership Organization and Type
138 $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}");
139 // Wait for membership type select to reload
140 $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']);
141 $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}");
143 $this->waitForElementPresent("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]");
144 $this->click("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]/span/a[text()='clear']");
146 $this->click("_qf_Membership_upload-bottom");
147 $this->waitForPageToLoad($this->getTimeoutMsec());
150 $this->waitForTextPresent($sourceText);
151 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
152 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
156 'Source' => $sourceText,
159 $this->webtestVerifyTabularData($verifyData);
162 function testMemberAddWithLifeTimeMembershipType() {
163 $this->open($this->sboxPath
);
164 $this->webtestLogin();
166 // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
167 $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime');
169 // Go directly to the URL of the screen that you will be testing (New Individual).
170 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
172 $firstName = "John_" . substr(sha1(rand()), 0, 7);
175 $this->type("first_name", $firstName);
178 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
179 $this->type("last_name", $lastName);
182 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
183 $this->type("email_1_email", $email);
186 $this->click("_qf_Contact_upload_view");
187 $this->waitForPageToLoad($this->getTimeoutMsec());
188 $this->assertElementContainsText('crm-notification-container', "$firstName $lastName has been created.");
190 // click through to the membership view screen
191 $this->click("css=li#tab_member a");
193 $this->waitForElementPresent("link=Add Membership");
194 $this->click("link=Add Membership");
196 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
198 // fill in Membership Organization and Type
199 $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}");
201 // Wait for membership type select to reload
202 $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']);
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");
217 $this->waitForPageToLoad($this->getTimeoutMsec());
220 $this->waitForTextPresent($sourceText);
222 // Is status message correct?
223 $this->assertElementContainsText('crm-notification-container', "membership for $firstName $lastName has been added.",
224 "Status message didn't show up after saving!");
226 // click through to the membership view screen
227 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
228 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
232 'Source' => $sourceText,
235 $this->webtestVerifyTabularData($verifyData);
236 $this->click("_qf_MembershipView_cancel-bottom");
237 $this->waitForPageToLoad($this->getTimeoutMsec());