3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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_TagTest
32 class WebTest_Import_TagTest
extends ImportCiviSeleniumTestCase
{
34 protected function setUp() {
39 * Test contact import for Individuals.
41 public function testContactImportWithTag() {
42 $this->webtestLogin();
44 // Get sample import data.
45 list($headers, $rows) = $this->_contactTagCSVData();
48 $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
50 // Import and check Individual contacts in Skip mode.
53 'createTagName' => $tagName,
56 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
58 $this->openCiviPage("contact/search", "reset=1");
59 $this->select('tag', "label={$tagName}");
61 $this->click('_qf_Basic_refresh');
62 $this->waitForPageToLoad($this->getTimeoutMsec());
65 $countContacts = count($rows);
66 // Is status message correct?
67 $this->assertTrue($this->isTextPresent("{$countContacts} Contacts"));
69 // Get sample import data.
70 list($headers, $rows) = $this->_contactTagCSVData();
72 // Import and check Individual contacts in Skip mode.
73 // Sending Tag Name For Re-use
74 $other = array('selectTag' => array($tagName));
76 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
78 $this->openCiviPage("contact/search", "reset=1");
80 $this->select('tag', "label={$tagName}");
82 $this->click('_qf_Basic_refresh');
83 $this->waitForPageToLoad($this->getTimeoutMsec());
85 //Counting Contact rows old rows + new rows
86 $countContacts +
= count($rows);
87 // Is status message correct?
88 $this->assertTrue($this->isTextPresent("{$countContacts} Contacts"));
92 * Helper function to provide data for contact import for sample.
96 public function _contactTagCSVData() {
98 'first_name' => 'First Name',
99 'middle_name' => 'Middle Name',
100 'last_name' => 'Last Name',
103 'address_1' => 'Additional Address 1',
104 'address_2' => 'Additional Address 2',
107 'country' => 'Country',
112 'first_name' => substr(sha1(rand()), 0, 7),
113 'middle_name' => substr(sha1(rand()), 0, 7),
114 'last_name' => 'Anderson',
115 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
116 'phone' => '6949912154',
117 'address_1' => 'Add 1',
118 'address_2' => 'Add 2',
121 'country' => 'UNITED STATES',
124 'first_name' => substr(sha1(rand()), 0, 7),
125 'middle_name' => substr(sha1(rand()), 0, 7),
126 'last_name' => 'Summerson',
127 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
128 'phone' => '6944412154',
129 'address_1' => 'Add 1',
130 'address_2' => 'Add 2',
133 'country' => 'UNITED STATES',
137 return array($headers, $rows);