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 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Member_UpdateMembershipScriptTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testAddMembership() { | |
6a488035 TO |
35 | // Log in using webtestLogin() method |
36 | $this->webtestLogin(); | |
37 | ||
38 | // Add a new membership type | |
39 | $memTypeParams = $this->addMembershipType(); | |
40 | ||
41 | $firstName = substr(sha1(rand()), 0, 7); | |
42 | $email = "$firstName.Anderson@example.com"; | |
43 | $this->webtestAddContact($firstName, 'Anderson', $email); | |
44 | ||
45 | $this->waitForElementPresent('css=li#tab_member a'); | |
46 | $this->click('css=li#tab_member a'); | |
47 | $this->waitForElementPresent('link=Add Membership'); | |
48 | $this->click('link=Add Membership'); | |
49 | ||
50 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
51 | $this->select('membership_type_id[0]', "label={$memTypeParams['member_of_contact']}"); | |
52 | $this->select('membership_type_id[1]', "label={$memTypeParams['membership_type']}"); | |
53 | ||
54 | // Fill join date | |
55 | $this->webtestFillDate('join_date', "1 March 2008"); | |
56 | ||
57 | // Override status | |
58 | $this->check('is_override'); | |
59 | $this->select('status_id', "label=Current"); | |
60 | ||
61 | // Clicking save. | |
62 | $this->click('_qf_Membership_upload'); | |
6a488035 TO |
63 | |
64 | // Is status message correct? | |
6c5f7368 | 65 | $this->waitForText('crm-notification-container', "{$memTypeParams['membership_type']} membership for $firstName Anderson has been added."); |
6a488035 TO |
66 | |
67 | // click through to the membership view screen | |
68 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]"); | |
69 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
70 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
71 | ||
72 | $this->webtestVerifyTabularData( | |
73 | array( | |
74 | 'Membership Type' => "{$memTypeParams['membership_type']}", | |
75 | 'Status' => 'Current', | |
76 | 'Member Since' => 'March 1st, 2008', | |
77 | 'Start date' => 'March 1st, 2008', | |
78 | 'End date' => 'February 28th, 2009', | |
79 | ) | |
80 | ); | |
81 | } | |
82 | ||
4cbe18b8 EM |
83 | /** |
84 | * @return array | |
85 | */ | |
6a488035 TO |
86 | function addMembershipType() { |
87 | $membershipTitle = substr(sha1(rand()), 0, 7); | |
88 | $membershipOrg = $membershipTitle . ' memorg'; | |
89 | $this->webtestAddOrganization($membershipOrg, TRUE); | |
90 | ||
91 | $title = "Membership Type " . substr(sha1(rand()), 0, 7); | |
92 | $memTypeParams = array( | |
93 | 'membership_type' => $title, | |
94 | 'member_of_contact' => $membershipOrg, | |
95 | 'financial_type' => 2, | |
96 | 'relationship_type' => '4_b_a', | |
97 | ); | |
98 | ||
6317df5c | 99 | $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); |
6a488035 TO |
100 | |
101 | $this->click("link=Add Membership Type"); | |
102 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
103 | ||
104 | // New membership type | |
105 | $this->type('name', $memTypeParams['membership_type']); | |
73072f84 | 106 | $this->select2('member_of_contact_id', $membershipTitle); |
6a488035 TO |
107 | |
108 | // Membership fees | |
109 | $this->type('minimum_fee', '100'); | |
110 | $this->select( 'financial_type_id', "value={$memTypeParams['financial_type']}" ); | |
111 | ||
112 | // Duration for which the membership will be active | |
113 | $this->type('duration_interval', 1); | |
114 | $this->select('duration_unit', "label=year"); | |
115 | ||
116 | // Membership period type | |
73072f84 | 117 | $this->select('period_type', "value=rolling"); |
6a488035 TO |
118 | $this->click('relationship_type_id', "value={$memTypeParams['relationship_type']}"); |
119 | ||
120 | // Clicking save | |
121 | $this->click('_qf_MembershipType_upload-bottom'); | |
122 | $this->waitForElementPresent('link=Add Membership Type'); | |
6c5f7368 | 123 | $this->waitForText('crm-notification-container', "The membership type '$title' has been saved."); |
6a488035 TO |
124 | |
125 | return $memTypeParams; | |
126 | } | |
42daf119 | 127 | } |