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