Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
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_GroupTest | |
31 | */ | |
6a488035 | 32 | class WebTest_Import_GroupTest extends ImportCiviSeleniumTestCase { |
6a488035 TO |
33 | |
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
c490a46a CW |
38 | /** |
39 | * Test contact import for Individuals. | |
40 | */ | |
00be9182 | 41 | public function testIndividualImportWithGroup() { |
6a488035 TO |
42 | $this->webtestLogin(); |
43 | ||
44 | // Get sample import data. | |
45 | list($headers, $rows) = $this->_individualGroupCSVData(); | |
46 | ||
47 | // Group Name | |
48 | $groupName = substr(sha1(rand()), 0, 7); | |
49 | ||
50 | // Import and check Individual Contacts in Skip mode and Add them in Group | |
51 | $other = array( | |
52 | 'createGroup' => TRUE, | |
53 | 'createGroupName' => $groupName, | |
54 | ); | |
55 | ||
56 | // Create New Group And Import Contacts In Group | |
57 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
58 | ||
59 | $count = count($rows); | |
60 | ||
61 | // Direct URL To Search | |
071a6d2e | 62 | $this->openCiviPage("contact/search", "reset=1"); |
6a488035 TO |
63 | |
64 | // Select GroupName | |
65 | $this->select("group", "label={$groupName}"); | |
66 | ||
beea38fc | 67 | $this->clickLink("_qf_Basic_refresh"); |
6a488035 TO |
68 | |
69 | // To Check Number Of Imported Contacts | |
70 | $this->assertTrue($this->isTextPresent("{$count} Contacts"), "Contacts Not Found"); | |
71 | ||
72 | // To Add New Contacts In Already Existing Group | |
73 | $other = array('selectGroup' => $groupName); | |
74 | ||
75 | // Create New Individual Record | |
76 | list($headers, $rows) = $this->_individualGroupCSVData(); | |
77 | ||
78 | // Import Contacts In Existing Group | |
79 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
80 | $count += count($rows); | |
81 | ||
82 | // Direct URL To Search | |
071a6d2e | 83 | $this->openCiviPage("contact/search", "reset=1"); |
6a488035 TO |
84 | |
85 | // Select GroupName | |
86 | $this->select("group", "label={$groupName}"); | |
87 | ||
beea38fc | 88 | $this->clickLink("_qf_Basic_refresh"); |
6a488035 TO |
89 | |
90 | // To Check Imported Contacts | |
91 | $this->assertTrue($this->isTextPresent("{$count} Contacts"), "Contacts Not Found"); | |
92 | } | |
93 | ||
4cbe18b8 | 94 | /** |
c490a46a CW |
95 | * Helper function to provide data for contact import for Individuals. |
96 | * | |
4cbe18b8 EM |
97 | * @return array |
98 | */ | |
00be9182 | 99 | public function _individualGroupCSVData() { |
6a488035 TO |
100 | $headers = array( |
101 | 'first_name' => 'First Name', | |
102 | 'middle_name' => 'Middle Name', | |
103 | 'last_name' => 'Last Name', | |
104 | 'email' => 'Email', | |
105 | 'phone' => 'Phone', | |
106 | 'address_1' => 'Additional Address 1', | |
107 | 'address_2' => 'Additional Address 2', | |
108 | 'city' => 'City', | |
109 | 'state' => 'State', | |
110 | 'country' => 'Country', | |
111 | ); | |
112 | ||
113 | $rows = array( | |
6c6e6187 | 114 | array( |
92915c55 | 115 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
116 | 'middle_name' => substr(sha1(rand()), 0, 7), |
117 | 'last_name' => 'Anderson', | |
118 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
119 | 'phone' => '6949912154', | |
120 | 'address_1' => 'Add 1', | |
121 | 'address_2' => 'Add 2', | |
122 | 'city' => 'Watson', | |
123 | 'state' => 'NY', | |
86797006 | 124 | 'country' => 'UNITED STATES', |
6a488035 | 125 | ), |
6c6e6187 | 126 | array( |
92915c55 | 127 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
128 | 'middle_name' => substr(sha1(rand()), 0, 7), |
129 | 'last_name' => 'Summerson', | |
130 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
131 | 'phone' => '6944412154', | |
132 | 'address_1' => 'Add 1', | |
133 | 'address_2' => 'Add 2', | |
134 | 'city' => 'Watson', | |
135 | 'state' => 'NY', | |
86797006 | 136 | 'country' => 'UNITED STATES', |
6a488035 TO |
137 | ), |
138 | ); | |
139 | return array($headers, $rows); | |
140 | } | |
96025800 | 141 | |
6a488035 | 142 | } |