3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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_TagTest
extends ImportCiviSeleniumTestCase
{
30 protected function setUp() {
35 * Test contact import for Individuals.
37 function testContactImportWithTag() {
38 $this->webtestLogin();
40 // Get sample import data.
41 list($headers, $rows) = $this->_contactTagCSVData();
44 $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
46 // Import and check Individual contacts in Skip mode.
49 'createTagName' => $tagName,
52 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
54 $this->openCiviPage("contact/search", "reset=1");
55 $this->select('tag', "label={$tagName}");
57 $this->click('_qf_Basic_refresh');
58 $this->waitForPageToLoad($this->getTimeoutMsec());
61 $countContacts = count($rows);
62 // Is status message correct?
63 $this->assertTrue($this->isTextPresent("{$countContacts} Contacts"));
65 // Get sample import data.
66 list($headers, $rows) = $this->_contactTagCSVData();
68 // Import and check Individual contacts in Skip mode.
69 // Sending Tag Name For Re-use
70 $other = array('selectTag' => array($tagName));
72 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
74 $this->openCiviPage("contact/search", "reset=1");
76 $this->select('tag', "label={$tagName}");
78 $this->click('_qf_Basic_refresh');
79 $this->waitForPageToLoad($this->getTimeoutMsec());
81 //Counting Contact rows old rows + new rows
82 $countContacts +
= count($rows);
83 // Is status message correct?
84 $this->assertTrue($this->isTextPresent("{$countContacts} Contacts"));
88 * Helper function to provide data for contact import for sample.
90 function _contactTagCSVData() {
92 'first_name' => 'First Name',
93 'middle_name' => 'Middle Name',
94 'last_name' => 'Last Name',
97 'address_1' => 'Additional Address 1',
98 'address_2' => 'Additional Address 2',
101 'country' => 'Country',
105 array('first_name' => substr(sha1(rand()), 0, 7),
106 'middle_name' => substr(sha1(rand()), 0, 7),
107 'last_name' => 'Anderson',
108 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
109 'phone' => '6949912154',
110 'address_1' => 'Add 1',
111 'address_2' => 'Add 2',
114 'country' => 'United States',
116 array('first_name' => substr(sha1(rand()), 0, 7),
117 'middle_name' => substr(sha1(rand()), 0, 7),
118 'last_name' => 'Summerson',
119 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
120 'phone' => '6944412154',
121 'address_1' => 'Add 1',
122 'address_2' => 'Add 2',
125 'country' => 'United States',
129 return array($headers, $rows);