3 class ConvertLeadTests extends Sugar_PHPUnit_Framework_TestCase
5 public function setUp()
7 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
8 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
11 public function tearDown()
13 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
14 unset($GLOBALS['app_list_strings']);
15 unset($GLOBALS['current_user']);
21 public function testOpportunityNameValueFilled(){
22 $lead = SugarTestLeadUtilities::createLead();
23 $lead->opportunity_name = 'SBizzle Dollar Store';
26 $_REQUEST['module'] = 'Leads';
27 $_REQUEST['action'] = 'ConvertLead';
28 $_REQUEST['record'] = $lead->id;
30 // Check that the opportunity name doesn't get populated when it's not in the Leads editview layout
31 require_once('include/MVC/Controller/ControllerFactory.php');
32 require_once('include/MVC/View/ViewFactory.php');
33 $GLOBALS['app']->controller = ControllerFactory::getController($_REQUEST['module']);
35 $GLOBALS['app']->controller->execute();
36 $output = ob_get_clean();
38 $matches_one = array();
39 $pattern = '/SBizzle Dollar Store/';
40 preg_match($pattern, $output, $matches_one);
41 $this->assertTrue(count($matches_one) == 0, "Opportunity name got carried over to the Convert Leads page when it shouldn't have.");
43 // Add the opportunity_name to the Leads EditView
44 SugarTestStudioUtilities::addFieldToLayout('Leads', 'editview', 'opportunity_name');
46 // Check that the opportunity name now DOES get populated now that it's in the Leads editview layout
48 $GLOBALS['app']->controller = ControllerFactory::getController($_REQUEST['module']);
49 $GLOBALS['app']->controller->execute();
50 $output = ob_get_clean();
51 $matches_two = array();
52 $pattern = '/SBizzle Dollar Store/';
53 preg_match($pattern, $output, $matches_two);
54 $this->assertTrue(count($matches_two) > 0, "Opportunity name did not carry over to the Convert Leads page when it should have.");
56 SugarTestStudioUtilities::removeAllCreatedFields();
57 unset($GLOBALS['app']->controller);
58 unset($_REQUEST['module']);
59 unset($_REQUEST['action']);
60 unset($_REQUEST['record']);
61 SugarTestLeadUtilities::removeAllCreatedLeads();