Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 TO |
27 | require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php'; |
28 | class WebTest_Import_TagTest extends ImportCiviSeleniumTestCase { | |
29 | ||
6a488035 TO |
30 | protected function setUp() { |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | /* | |
35 | * Test contact import for Individuals. | |
36 | */ | |
37 | function testContactImportWithTag() { | |
6a488035 TO |
38 | $this->webtestLogin(); |
39 | ||
40 | // Get sample import data. | |
41 | list($headers, $rows) = $this->_contactTagCSVData(); | |
42 | ||
43 | // Creating a new Tag | |
44 | $tagName = 'tag_' . substr(sha1(rand()), 0, 7); | |
45 | ||
46 | // Import and check Individual contacts in Skip mode. | |
47 | $other = array( | |
48 | 'createTag' => TRUE, | |
49 | 'createTagName' => $tagName, | |
50 | ); | |
51 | ||
52 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
53 | ||
071a6d2e | 54 | $this->openCiviPage("contact/search", "reset=1"); |
6a488035 TO |
55 | $this->select('tag', "label={$tagName}"); |
56 | // click to search | |
57 | $this->click('_qf_Basic_refresh'); | |
58 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
59 | ||
60 | // count rows | |
61 | $countContacts = count($rows); | |
62 | // Is status message correct? | |
63 | $this->assertTrue($this->isTextPresent("{$countContacts} Contacts")); | |
64 | ||
65 | // Get sample import data. | |
66 | list($headers, $rows) = $this->_contactTagCSVData(); | |
67 | ||
68 | // Import and check Individual contacts in Skip mode. | |
69 | // Sending Tag Name For Re-use | |
70 | $other = array('selectTag' => array($tagName)); | |
71 | ||
72 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
73 | ||
071a6d2e | 74 | $this->openCiviPage("contact/search", "reset=1"); |
6a488035 TO |
75 | |
76 | $this->select('tag', "label={$tagName}"); | |
77 | // click to search | |
78 | $this->click('_qf_Basic_refresh'); | |
79 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
80 | ||
81 | //Counting Contact rows old rows + new rows | |
82 | $countContacts += count($rows); | |
83 | // Is status message correct? | |
84 | $this->assertTrue($this->isTextPresent("{$countContacts} Contacts")); | |
85 | } | |
86 | ||
87 | /* | |
88 | * Helper function to provide data for contact import for sample. | |
89 | */ | |
4cbe18b8 EM |
90 | /** |
91 | * @return array | |
92 | */ | |
6a488035 TO |
93 | function _contactTagCSVData() { |
94 | $headers = array( | |
95 | 'first_name' => 'First Name', | |
96 | 'middle_name' => 'Middle Name', | |
97 | 'last_name' => 'Last Name', | |
98 | 'email' => 'Email', | |
99 | 'phone' => 'Phone', | |
100 | 'address_1' => 'Additional Address 1', | |
101 | 'address_2' => 'Additional Address 2', | |
102 | 'city' => 'City', | |
103 | 'state' => 'State', | |
104 | 'country' => 'Country', | |
105 | ); | |
106 | ||
107 | $rows = array( | |
108 | array('first_name' => substr(sha1(rand()), 0, 7), | |
109 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
110 | 'last_name' => 'Anderson', | |
111 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
112 | 'phone' => '6949912154', | |
113 | 'address_1' => 'Add 1', | |
114 | 'address_2' => 'Add 2', | |
115 | 'city' => 'Watson', | |
116 | 'state' => 'NY', | |
117 | 'country' => 'United States', | |
118 | ), | |
119 | array('first_name' => substr(sha1(rand()), 0, 7), | |
120 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
121 | 'last_name' => 'Summerson', | |
122 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
123 | 'phone' => '6944412154', | |
124 | 'address_1' => 'Add 1', | |
125 | 'address_2' => 'Add 2', | |
126 | 'city' => 'Watson', | |
127 | 'state' => 'NY', | |
128 | 'country' => 'United States', | |
129 | ), | |
130 | ); | |
131 | ||
132 | return array($headers, $rows); | |
133 | } | |
134 | } | |
135 |