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