Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | ||
27 | ||
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
29 | class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase { | |
30 | ||
31 | protected function setUp() { | |
32 | parent::setUp(); | |
33 | } | |
34 | ||
35 | function testStandaloneMemberAdd() { | |
36 | ||
37 | $this->open($this->sboxPath); | |
38 | $this->webtestLogin(); | |
39 | ||
40 | // create contact | |
41 | $firstName = substr(sha1(rand()), 0, 7); | |
42 | $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name"); | |
43 | $contactName = "Memberson, $firstName"; | |
44 | ||
45 | // add membership type | |
46 | $membershipTypes = $this->webtestAddMembershipType(); | |
47 | ||
48 | // now add membership | |
49 | $this->open($this->sboxPath . "civicrm/member/add?reset=1&action=add&context=standalone"); | |
50 | ||
51 | $this->waitForElementPresent("_qf_Membership_upload"); | |
52 | ||
53 | // select contact | |
54 | $this->webtestFillAutocomplete($firstName); | |
55 | ||
56 | // fill in Membership Organization | |
57 | $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}"); | |
58 | ||
59 | // select membership type | |
60 | $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}"); | |
61 | ||
62 | // fill in Source | |
63 | $this->type("source", "Membership StandaloneAddTest Webtest"); | |
64 | ||
65 | // Let Join Date stay default | |
66 | ||
67 | // fill in Start Date | |
68 | $this->webtestFillDate('start_date'); | |
69 | ||
70 | // Let End Date be auto computed | |
71 | ||
72 | // fill in Status Override? | |
73 | // fill in Record Membership Payment? | |
74 | ||
75 | $this->click("_qf_Membership_upload"); | |
76 | ||
77 | //View Membership | |
78 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
79 | $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']"); | |
80 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
81 | $expected = array( | |
82 | 2 => $membershipTypes['membership_type'], | |
83 | 3 => 'New', | |
84 | 4 => 'Membership StandaloneAddTest Webtest', | |
85 | ); | |
86 | foreach ($expected as $label => $value) { | |
87 | $this->verifyText("xpath=id('MembershipView')/div[2]/div/table[1]/tbody/tr[$label]/td[2]", preg_quote($value)); | |
88 | } | |
89 | } | |
90 | ||
91 | function testStandaloneMemberOverrideAdd() { | |
92 | ||
93 | $this->open($this->sboxPath); | |
94 | $this->webtestLogin(); | |
95 | ||
96 | // add contact | |
97 | $firstName = substr(sha1(rand()), 0, 7); | |
98 | $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name"); | |
99 | $contactName = "Memberson, $firstName"; | |
100 | ||
101 | // add membership type | |
102 | $membershipTypes = $this->webtestAddMembershipType(); | |
103 | ||
104 | // add membership | |
105 | $this->open($this->sboxPath . "civicrm/member/add?reset=1&action=add&context=standalone"); | |
106 | ||
107 | $this->waitForElementPresent("_qf_Membership_upload"); | |
108 | ||
109 | // select contact | |
110 | $this->webtestFillAutocomplete($firstName); | |
111 | ||
112 | // fill in Membership Organization | |
113 | $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}"); | |
114 | ||
115 | // select membership type | |
116 | $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}"); | |
117 | ||
118 | // fill in Source | |
119 | $this->type("source", "Membership StandaloneAddTest Webtest"); | |
120 | ||
121 | // Let Join Date stay default | |
122 | ||
123 | // fill in Start Date | |
124 | $this->webtestFillDate('start_date'); | |
125 | ||
126 | // Let End Date be auto computed | |
127 | ||
128 | // fill in Status Override? | |
129 | $this->click("is_override", "value=1"); | |
130 | $this->waitForElementPresent("status_id"); | |
131 | $this->select("status_id", "value=3"); | |
132 | ||
133 | // fill in Record Membership Payment? | |
134 | $this->click("record_contribution", "value=1"); | |
135 | $this->waitForElementPresent("contribution_status_id"); | |
136 | // let financial type be default | |
137 | ||
138 | // let the amount be default | |
139 | ||
140 | // select payment instrument type = Check and enter chk number | |
141 | $this->select("payment_instrument_id", "value=4"); | |
142 | $this->waitForElementPresent("check_number"); | |
143 | $this->type("check_number", "check #12345"); | |
144 | $this->type("trxn_id", "P5476785" . rand(100, 10000)); | |
145 | ||
146 | // fill the payment status be default | |
147 | $this->select("contribution_status_id", "value=2"); | |
148 | ||
149 | //---- | |
150 | ||
151 | // Clicking save. | |
152 | $this->click("_qf_Membership_upload"); | |
153 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
154 | ||
155 | // page was loaded | |
156 | $this->waitForTextPresent("Membership StandaloneAddTest Webtest"); | |
157 | ||
158 | // verify if Membership is created | |
159 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
160 | ||
161 | //click through to the Membership view screen | |
162 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
163 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
164 | ||
165 | $expected = array( | |
166 | 2 => $membershipTypes['membership_type'], | |
167 | 3 => 'Grace', | |
168 | 4 => 'Membership StandaloneAddTest Webtest', | |
169 | ); | |
170 | foreach ($expected as $label => $value) { | |
171 | $this->verifyText("xpath=id('MembershipView')/div[2]/div/table[1]/tbody/tr[$label]/td[2]", preg_quote($value)); | |
172 | } | |
173 | } | |
174 | } | |
175 | ||
176 |