3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 +--------------------------------------------------------------------+
27 require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
30 * Class WebTest_Import_ParticipantTest
32 class WebTest_Import_ParticipantTest
extends ImportCiviSeleniumTestCase
{
34 protected function setUp() {
39 * Test participant import for Individuals.
41 public function testParticipantImportIndividual() {
42 // Log in using webtestLogin() method
43 $this->webtestLogin();
45 // Get sample import data.
46 list($headers, $rows) = $this->_participantIndividualCSVData();
48 // Create and import csv from provided data and check imported data.
50 'mapper[0][0]' => 'email',
51 'mapper[1][0]' => 'event_id',
52 'mapper[2][0]' => 'participant_fee_level',
53 'mapper[4][0]' => 'participant_status_id',
56 $this->importCSVComponent('Event', $headers, $rows, 'Individual', 'Skip', $fieldMapper);
60 * Test participant import for Organizations.
62 public function testParticipantImportOrganization() {
63 // Log in using webtestLogin() method
64 $this->webtestLogin();
66 // Get sample import data.
67 list($headers, $rows) = $this->_participantOrganizationCSVData();
69 // Create and import csv from provided data and check imported data.
71 'mapper[0][0]' => 'organization_name',
72 'mapper[1][0]' => 'event_id',
73 'mapper[2][0]' => 'participant_fee_level',
74 'mapper[4][0]' => 'participant_status_id',
77 $this->importCSVComponent('Event', $headers, $rows, 'Organization', 'Skip', $fieldMapper);
81 * Test participant import for Households.
83 public function testParticipantImportHousehold() {
84 // Log in using webtestLogin() method
85 $this->webtestLogin();
87 // Get sample import data.
88 list($headers, $rows) = $this->_participantHouseholdCSVData();
90 // Create and import csv from provided data and check imported data.
92 'mapper[0][0]' => 'household_name',
93 'mapper[1][0]' => 'event_id',
94 'mapper[2][0]' => 'participant_fee_level',
95 'mapper[4][0]' => 'participant_status_id',
98 $this->importCSVComponent('Event', $headers, $rows, 'Household', 'Skip', $fieldMapper);
102 * Helper function to provide data for participant import for Individuals.
106 public function _participantIndividualCSVData() {
107 $eventInfo = $this->_addNewEvent();
109 $firstName1 = substr(sha1(rand()), 0, 7);
110 $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
111 $this->webtestAddContact($firstName1, 'Anderson', $email1);
113 $firstName2 = substr(sha1(rand()), 0, 7);
114 $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
115 $this->webtestAddContact($firstName2, 'Anderson', $email2);
119 'event_id' => 'Event Id',
120 'fee_level' => 'Fee Level',
121 'role' => 'Participant Role',
122 'status' => 'Participant Status',
123 'register_date' => 'Register date',
129 'event_id' => $eventInfo['event_id'],
130 'fee_level' => 'Member',
133 'register_date' => '2011-03-30',
137 'event_id' => $eventInfo['event_id'],
138 'fee_level' => 'Non-Member',
141 'register_date' => '2011-03-30',
145 return array($headers, $rows);
149 * Helper function to provide data for participant import for Household.
153 public function _participantHouseholdCSVData() {
154 $eventInfo = $this->_addNewEvent();
156 $household1 = substr(sha1(rand()), 0, 7) . ' home';
157 $this->webtestAddHousehold($household1, TRUE);
159 $household2 = substr(sha1(rand()), 0, 7) . ' home';
160 $this->webtestAddHousehold($household2, TRUE);
163 'household' => 'Household Name',
164 'event_id' => 'Event Id',
165 'fee_level' => 'Fee Level',
166 'role' => 'Participant Role',
167 'status' => 'Participant Status',
168 'register_date' => 'Register date',
173 'household' => $household1,
174 'event_id' => $eventInfo['event_id'],
175 'fee_level' => 'Member',
178 'register_date' => '2011-03-30',
181 'household' => $household2,
182 'event_id' => $eventInfo['event_id'],
183 'fee_level' => 'Non-Member',
186 'register_date' => '2011-03-30',
190 return array($headers, $rows);
194 * Helper function to provide data for participant import for Organization.
197 public function _participantOrganizationCSVData() {
198 $eventInfo = $this->_addNewEvent();
200 $organization1 = substr(sha1(rand()), 0, 7) . ' org';
201 $this->webtestAddOrganization($organization1, TRUE);
203 $organization2 = substr(sha1(rand()), 0, 7) . ' org';
204 $this->webtestAddOrganization($organization2, TRUE);
207 'organization' => 'Organization Name',
208 'event_id' => 'Event Id',
209 'fee_level' => 'Fee Level',
210 'role' => 'Participant Role',
211 'status' => 'Participant Status',
212 'register_date' => 'Register date',
217 'organization' => $organization1,
218 'event_id' => $eventInfo['event_id'],
219 'fee_level' => 'Member',
222 'register_date' => '2011-03-30',
225 'organization' => $organization2,
226 'event_id' => $eventInfo['event_id'],
227 'fee_level' => 'Non-Member',
230 'register_date' => '2011-03-30',
234 return array($headers, $rows);
238 * Helper function to add new event.
240 * @param array $params
241 * Parameters to create an event.
244 * event details of newly created event
246 public function _addNewEvent($params = array()) {
248 if (empty($params)) {
250 // Use default payment processor
251 $processorName = 'Test Processor';
252 $this->webtestAddPaymentProcessor($processorName);
255 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
257 'title' => $eventTitle,
259 'event_type_id' => 4,
260 'payment_processor' => $processorName,
261 'fee_level' => array(
262 'Member' => "250.00",
263 'Non-Member' => "325.00",
268 $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
270 $this->select("event_type_id", "value={$params['event_type_id']}");
272 // Attendee role s/b selected now.
273 $this->select("default_role_id", "value=1");
275 // Enter Event Title, Summary and Description
276 $this->type("title", $params['title']);
277 $this->type("summary", "This is a great conference. Sign up now!");
278 $this->fillRichTextField("description", "Here is a description for this event.", 'CKEditor');
280 // Choose Start and End dates.
281 // Using helper webtestFillDate function.
282 $this->webtestFillDateTime("start_date", "+1 week");
283 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
285 $this->type("max_participants", "50");
286 $this->click("is_map");
287 $this->click("_qf_EventInfo_upload-bottom");
289 // Wait for Location tab form to load
290 $this->waitForPageToLoad($this->getTimeoutMsec());
293 $this->click("link=Fees");
294 $this->waitForElementPresent("_qf_Fee_upload-bottom");
295 $this->click("CIVICRM_QFID_1_is_monetary");
297 // select newly created processor
298 $this->select2('payment_processor', $processorName, TRUE);
299 $this->assertElementContainsText('paymentProcessor', $processorName);
300 $this->select("financial_type_id", "value=4");
303 foreach ($params['fee_level'] as $label => $amount) {
304 $this->type("label_{$counter}", $label);
305 $this->type("value_{$counter}", $amount);
309 $this->click("_qf_Fee_upload-bottom");
310 $this->waitForElementPresent("_qf_Fee_upload-bottom");
312 // Go to Online Registration tab
313 $this->click("link=Online Registration");
314 $this->waitForElementPresent("_qf_Registration_upload-bottom");
316 $this->click("is_online_registration");
317 $this->assertChecked("is_online_registration");
319 $this->fillRichTextField("intro_text", "Fill in all the fields below and click Continue.", 'CKEditor', TRUE);
321 // enable confirmation email
322 $this->click("CIVICRM_QFID_1_is_email_confirm");
323 $this->type("confirm_from_name", "Jane Doe");
324 $this->type("confirm_from_email", "jane.doe@example.org");
326 $this->click("_qf_Registration_upload-bottom");
327 $this->waitForElementPresent("_qf_Registration_upload-bottom");
328 $this->waitForTextPresent("'Online Registration' information has been saved.");
330 // verify event input on info page
331 // start at Manage Events listing
332 $this->openCiviPage('event/manage', 'reset=1');
333 $this->clickLink("link=" . $params['title'], NULL);
335 $params['event_id'] = $this->urlArg('id');;