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