2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
37 require_once 'modules/Campaigns/Campaign.php';
38 require_once 'modules/CampaignTrackers/CampaignTracker.php';
40 class CampaignTrackersTest extends Sugar_PHPUnit_Framework_TestCase
42 var $campaign = 'campaignforcamplogunittest';
43 var $campaign_tracker;
46 public function setup()
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
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;
62 $c->team_set_id = '1';
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;
72 $this->campaign_tracker = $ct;
79 public function tearDown()
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 );
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');
98 public function testFillInAdditionalDetailFields(){
101 $this->campaign_tracker->fill_in_additional_detail_fields();
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');
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');
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');