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';
30 * Class WebTest_Import_GroupTest
32 class WebTest_Import_GroupTest
extends ImportCiviSeleniumTestCase
{
34 protected function setUp() {
39 * Test contact import for Individuals.
41 function testIndividualImportWithGroup() {
42 $this->webtestLogin();
44 // Get sample import data.
45 list($headers, $rows) = $this->_individualGroupCSVData();
48 $groupName = substr(sha1(rand()), 0, 7);
50 // Import and check Individual Contacts in Skip mode and Add them in Group
52 'createGroup' => TRUE,
53 'createGroupName' => $groupName,
56 // Create New Group And Import Contacts In Group
57 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
59 $count = count($rows);
61 // Direct URL To Search
62 $this->openCiviPage("contact/search", "reset=1");
65 $this->select("group", "label={$groupName}");
67 $this->click("_qf_Basic_refresh");
68 $this->waitForPageToLoad($this->getTimeoutMsec());
70 // To Check Number Of Imported Contacts
71 $this->assertTrue($this->isTextPresent("{$count} Contacts"), "Contacts Not Found");
73 // To Add New Contacts In Already Existing Group
74 $other = array('selectGroup' => $groupName);
76 // Create New Individual Record
77 list($headers, $rows) = $this->_individualGroupCSVData();
79 // Import Contacts In Existing Group
80 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
81 $count +
= count($rows);
83 // Direct URL To Search
84 $this->openCiviPage("contact/search", "reset=1");
87 $this->select("group", "label={$groupName}");
89 $this->click("_qf_Basic_refresh");
90 $this->waitForPageToLoad($this->getTimeoutMsec());
92 // To Check Imported Contacts
93 $this->assertTrue($this->isTextPresent("{$count} Contacts"), "Contacts Not Found");
97 * Helper function to provide data for contact import for Individuals.
102 function _individualGroupCSVData() {
104 'first_name' => 'First Name',
105 'middle_name' => 'Middle Name',
106 'last_name' => 'Last Name',
109 'address_1' => 'Additional Address 1',
110 'address_2' => 'Additional Address 2',
113 'country' => 'Country',
117 array('first_name' => substr(sha1(rand()), 0, 7),
118 'middle_name' => substr(sha1(rand()), 0, 7),
119 'last_name' => 'Anderson',
120 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
121 'phone' => '6949912154',
122 'address_1' => 'Add 1',
123 'address_2' => 'Add 2',
126 'country' => 'United States',
128 array('first_name' => substr(sha1(rand()), 0, 7),
129 'middle_name' => substr(sha1(rand()), 0, 7),
130 'last_name' => 'Summerson',
131 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
132 'phone' => '6944412154',
133 'address_1' => 'Add 1',
134 'address_2' => 'Add 2',
137 'country' => 'United States',
140 return array($headers, $rows);