3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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';
28 class WebTest_Import_GroupTest
extends ImportCiviSeleniumTestCase
{
30 protected function setUp() {
35 * Test contact import for Individuals.
37 function testIndividualImportWithGroup() {
38 $this->webtestLogin();
40 // Get sample import data.
41 list($headers, $rows) = $this->_individualGroupCSVData();
44 $groupName = substr(sha1(rand()), 0, 7);
46 // Import and check Individual Contacts in Skip mode and Add them in Group
48 'createGroup' => TRUE,
49 'createGroupName' => $groupName,
52 // Create New Group And Import Contacts In Group
53 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
55 $count = count($rows);
57 // Direct URL To Search
58 $this->openCiviPage("contact/search", "reset=1");
61 $this->select("group", "label={$groupName}");
63 $this->click("_qf_Basic_refresh");
64 $this->waitForPageToLoad($this->getTimeoutMsec());
66 // To Check Number Of Imported Contacts
67 $this->assertTrue($this->isTextPresent("{$count} Contacts"), "Contacts Not Found");
69 // To Add New Contacts In Already Existing Group
70 $other = array('selectGroup' => $groupName);
72 // Create New Individual Record
73 list($headers, $rows) = $this->_individualGroupCSVData();
75 // Import Contacts In Existing Group
76 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
77 $count +
= count($rows);
79 // Direct URL To Search
80 $this->openCiviPage("contact/search", "reset=1");
83 $this->select("group", "label={$groupName}");
85 $this->click("_qf_Basic_refresh");
86 $this->waitForPageToLoad($this->getTimeoutMsec());
88 // To Check Imported Contacts
89 $this->assertTrue($this->isTextPresent("{$count} Contacts"), "Contacts Not Found");
93 * Helper function to provide data for contact import for Individuals.
95 function _individualGroupCSVData() {
97 'first_name' => 'First Name',
98 'middle_name' => 'Middle Name',
99 'last_name' => 'Last Name',
102 'address_1' => 'Additional Address 1',
103 'address_2' => 'Additional Address 2',
106 'country' => 'Country',
110 array('first_name' => substr(sha1(rand()), 0, 7),
111 'middle_name' => substr(sha1(rand()), 0, 7),
112 'last_name' => 'Anderson',
113 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
114 'phone' => '6949912154',
115 'address_1' => 'Add 1',
116 'address_2' => 'Add 2',
119 'country' => 'United States',
121 array('first_name' => substr(sha1(rand()), 0, 7),
122 'middle_name' => substr(sha1(rand()), 0, 7),
123 'last_name' => 'Summerson',
124 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
125 'phone' => '6944412154',
126 'address_1' => 'Add 1',
127 'address_2' => 'Add 2',
130 'country' => 'United States',
133 return array($headers, $rows);