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_ActivityTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Import_ActivityTest extends ImportCiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testActivityImport() { |
6a488035 TO |
39 | |
40 | $this->webtestLogin(); | |
41 | ||
42 | // Get sample import data. | |
43 | list($headers, $rows) = $this->_activityCSVData(); | |
44 | $fieldMapper = array( | |
3045c37b | 45 | 'mapper[0][0]' => 'target_contact_id', |
6a488035 TO |
46 | 'mapper[1][0]' => 'activity_label', |
47 | 'mapper[2][0]' => 'activity_subject', | |
48 | 'mapper[3][0]' => 'activity_date_time', | |
49 | ); | |
50 | $this->importCSVComponent('Activity', $headers, $rows, NULL, NULL, $fieldMapper); | |
51 | } | |
52 | ||
4cbe18b8 EM |
53 | /** |
54 | * @return array | |
55 | */ | |
00be9182 | 56 | public function _activityCSVData() { |
6a488035 TO |
57 | |
58 | $firstName1 = substr(sha1(rand()), 0, 7); | |
59 | $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com'; | |
60 | $this->webtestAddContact($firstName1, 'Anderson', $email1); | |
a471a3b6 | 61 | $id1 = $this->urlArg('cid'); |
6a488035 TO |
62 | |
63 | $firstName2 = substr(sha1(rand()), 0, 7); | |
64 | $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com'; | |
65 | $this->webtestAddContact($firstName2, 'Anderson', $email2); | |
a471a3b6 | 66 | $id2 = $this->urlArg('cid'); |
6a488035 TO |
67 | |
68 | $headers = array( | |
69 | 'target_contact_id' => 'Contact ID', | |
70 | 'activity_type_label' => 'Activity Type Label', | |
71 | 'subject' => 'Subject', | |
72 | 'activity_date' => 'Activity Date', | |
73 | 'activity_status_id' => 'Activity Status Id', | |
74 | 'duration' => 'Duration', | |
75 | 'location' => 'Location', | |
76 | ); | |
77 | ||
78 | $rows = array( | |
79 | array( | |
80 | 'target_contact_id' => $id1, | |
81 | 'activity_type_label' => 'Meeting', | |
82 | 'subject' => 'Test Meeting', | |
83 | 'activity_date' => '2009-10-01', | |
84 | 'activity_status_id' => 'Completed', | |
85 | 'duration' => '20', | |
86 | 'location' => 'UK', | |
87 | ), | |
88 | array( | |
89 | 'target_contact_id' => $id2, | |
90 | 'activity_type_label' => 'Phone Call', | |
91 | 'subject' => 'Test Phone Call', | |
92 | 'activity_date' => '2010-10-15', | |
93 | 'activity_status_id' => 'Completed', | |
94 | 'duration' => '20', | |
95 | 'location' => 'USA', | |
96 | ), | |
97 | ); | |
98 | ||
99 | return array($headers, $rows); | |
100 | } | |
96025800 | 101 | |
6a488035 | 102 | } |