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_UpdateMembershipScriptTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testAddMembership() {
36 // This is the path where our testing install resides.
37 // The rest of URL is defined in CiviSeleniumTestCase base class, in
39 $this->open($this->sboxPath
);
41 // Log in using webtestLogin() method
42 $this->webtestLogin();
44 // Add a new membership type
45 $memTypeParams = $this->addMembershipType();
47 $firstName = substr(sha1(rand()), 0, 7);
48 $email = "$firstName.Anderson@example.com";
49 $this->webtestAddContact($firstName, 'Anderson', $email);
51 $this->waitForElementPresent('css=li#tab_member a');
52 $this->click('css=li#tab_member a');
53 $this->waitForElementPresent('link=Add Membership');
54 $this->click('link=Add Membership');
56 $this->waitForElementPresent('_qf_Membership_cancel-bottom');
57 $this->select('membership_type_id[0]', "label={$memTypeParams['member_of_contact']}");
58 $this->select('membership_type_id[1]', "label={$memTypeParams['membership_type']}");
61 $this->webtestFillDate('join_date', "1 March 2008");
64 $this->check('is_override');
65 $this->select('status_id', "label=Current");
68 $this->click('_qf_Membership_upload');
69 $this->waitForPageToLoad($this->getTimeoutMsec());
71 // Is status message correct?
72 $this->assertElementContainsText('crm-notification-container', "{$memTypeParams['membership_type']} membership for $firstName Anderson has been added.",
73 "Status message didn't show up after saving!"
76 // click through to the membership view screen
77 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]");
78 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
79 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
81 $this->webtestVerifyTabularData(
83 'Membership Type' => "{$memTypeParams['membership_type']}",
84 'Status' => 'Current',
85 'Member Since' => 'March 1st, 2008',
86 'Start date' => 'March 1st, 2008',
87 'End date' => 'February 28th, 2009',
92 function addMembershipType() {
93 $membershipTitle = substr(sha1(rand()), 0, 7);
94 $membershipOrg = $membershipTitle . ' memorg';
95 $this->webtestAddOrganization($membershipOrg, TRUE);
97 $title = "Membership Type " . substr(sha1(rand()), 0, 7);
98 $memTypeParams = array(
99 'membership_type' => $title,
100 'member_of_contact' => $membershipOrg,
101 'financial_type' => 2,
102 'relationship_type' => '4_b_a',
105 $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse');
107 $this->click("link=Add Membership Type");
108 $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
110 // New membership type
111 $this->type('name', $memTypeParams['membership_type']);
112 $this->type('member_of_contact', $membershipTitle);
113 $this->click('member_of_contact');
114 $this->waitForElementPresent("css=div.ac_results-inner li");
115 $this->click("css=div.ac_results-inner li");
118 $this->type('minimum_fee', '100');
119 $this->select( 'financial_type_id', "value={$memTypeParams['financial_type']}" );
121 // Duration for which the membership will be active
122 $this->type('duration_interval', 1);
123 $this->select('duration_unit', "label=year");
125 // Membership period type
126 $this->select('period_type', "label=rolling");
127 $this->click('relationship_type_id', "value={$memTypeParams['relationship_type']}");
130 $this->click('_qf_MembershipType_upload-bottom');
131 $this->waitForElementPresent('link=Add Membership Type');
132 $this->assertElementContainsText('crm-notification-container', "The membership type '$title' has been saved.");
134 return $memTypeParams;