2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2012 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 ********************************************************************************/
38 require_once 'include/SubPanel/SubPanelTiles.php';
42 * Subject Blank Rows Are Displayed In Campaign Status "Leads Created" Subpanel If Leads Are Deleted
46 class Bug41523Test extends Sugar_PHPUnit_Framework_TestCase
58 public function setUp()
60 $this->markTestIncomplete("This test breaks on stack66 - working with dev to fix");
63 // Init session user settings
64 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
65 $GLOBALS['current_user']->setPreference('max_tabs', 2);
67 $this->campaign = SugarTestCampaignUtilities::createCampaign();
68 $this->db = $GLOBALS['db'];
69 $focus = $this->campaign;
71 // Setting for SubPanel
72 $_SERVER['REQUEST_METHOD'] = 'GET';
73 $_REQUEST['module'] = 'Campaigns';
74 $_REQUEST['action'] = 'TrackDetailView';
75 $_REQUEST['record'] = $this->campaign->id;
78 public function tearDown()
80 // Delete created campaings
81 SugarTestCampaignUtilities::removeAllCreatedCampaigns();
84 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
90 public function testDeletedLeadsOnCapmaingStatusPage()
93 $lead1 = $this->createLeadFromWebForm('User1');
94 $lead2 = $this->createLeadFromWebForm('User2');
97 $lead1->mark_deleted($lead1->id);
99 $this->assertEquals($this->campaign->getDeletedCampaignLogLeadsCount(), 1);
101 // Test SubPanel output
102 $subpanel = new SubPanelTiles($this->campaign, 'Campaigns');
103 $html = $subpanel->display();
105 preg_match('|<div id="list_subpanel_lead">.*?<table.*?</table>.*?</table>.*?</tr>(.*?)</table>|s', $html, $match);
106 preg_match_all('|<tr|', $match[1], $match);
108 $this->assertEquals(count($match[0]), 2);
112 * @param $lastName Last name for new lead
116 private function createLeadFromWebForm($lastName)
119 'last_name' => $lastName,
120 'campaign_id' => $this->campaign->id,
123 // Send request for add lead
125 curl_setopt($ch, CURLOPT_URL, $GLOBALS['sugar_config']['site_url'] . '/index.php?entryPoint=WebToLeadCapture');
126 curl_setopt($ch, CURLOPT_POST, true);
127 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
128 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
129 $response = curl_exec($ch);
131 $this->assertEquals('Thank You For Your Submission.', $response);
135 // Fetch last created lead
136 $createdLead = new Lead();
137 $query = 'SELECT * FROM leads ORDER BY date_entered DESC LIMIT 1';
138 $createdLead->fromArray($this->db->fetchOne($query));