]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/CampaignTrackers/CampaignTrackersTest.php
Release 6.2.0
[Github/sugarcrm.git] / tests / modules / CampaignTrackers / CampaignTrackersTest.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5  * 
6  * This program is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  * 
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
16  * details.
17  * 
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  * 
23  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25  * 
26  * The interactive user interfaces in modified source and object code versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  * 
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the "Powered by
32  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33  * technical reasons, the Appropriate Legal Notices must display the words
34  * "Powered by SugarCRM".
35  ********************************************************************************/
36
37 require_once 'modules/Campaigns/Campaign.php';
38 require_once 'modules/CampaignTrackers/CampaignTracker.php';
39
40 class CampaignTrackersTest extends Sugar_PHPUnit_Framework_TestCase
41 {
42         var $campaign = 'campaignforcamplogunittest';
43         var $campaign_tracker;
44
45     
46     public function setup()
47     {
48                 global $current_user;   
49
50                 $current_user = SugarTestUserUtilities::createAnonymousUser();
51                 //for the purpose of this test, we need to create a campaign and relate it to a campaign tracker object
52
53                 //create campaign
54         $c = new Campaign();
55         $c->name = 'CT test ' . time();
56         $c->campaign_type = 'Email';
57         $c->status = 'Active';
58         $timeDate = new TimeDate();
59         $c->end_date = $timeDate->to_display_date(date('Y')+1 .'-01-01');
60         $c->assigned_id = $current_user->id;
61         $c->team_id = '1';
62         $c->team_set_id = '1';
63         $c->save();             
64                 $this->campaign = $c;
65                 
66                 //create campaign tracker
67                 $ct = new CampaignTracker();
68                 $ct->tracker_name ='CampaignTrackerTest' . time();
69                 $ct->tracker_url = 'sugarcrm.com';
70                 $ct->campaign_id = $this->campaign->id;
71                 $ct->save();
72                 $this->campaign_tracker = $ct;
73
74
75
76                 
77     }
78     
79     public function tearDown()
80     {
81                 //delete the campaign and campaign tracker
82                 $GLOBALS['db']->query('DELETE FROM campaign_log WHERE campaign_id = \''.$this->campaign->id.'\' ');
83                 $GLOBALS['db']->query('DELETE FROM campaign_trkrs WHERE id = \''.$this->campaign_tracker->id.'\' ');
84                 unset($this->campaign_tracker);
85         unset($this->campaign_log );
86         unset($current_user);
87     }
88         
89
90         public function testSave(){
91                 //save was already performed, so just confirm that the http protocol got added on save
92                 $this->assertSame('http://sugarcrm.com', $this->campaign_tracker->tracker_url, 'http protocol was not added to campaign_tracker->tracker_url on save');
93                 
94         }
95         
96         
97
98         public function testFillInAdditionalDetailFields(){
99                 global $current_user;
100
101                 $this->campaign_tracker->fill_in_additional_detail_fields();
102
103                 //test that campaign name gets filled in
104                 $this->assertSame($this->campaign->name, $this->campaign_tracker->campaign_name, 'campaign name was not set properly during function call');
105
106                 //test that message url gets filed out
107                 $this->assertFalse(empty($this->campaign_tracker->message_url), 'message url was not populated correctly during function call');                
108         }
109
110         public function testGetSummaryText(){
111                 //test that tracker name is returned
112                 $this->assertSame($this->campaign_tracker->tracker_name, $this->campaign_tracker->get_summary_text(), 'campaign tracker name is not set properly in summary text');
113                 
114         }
115
116
117         
118
119 }