public function handleSaveAndRetrieveSavedSearch($id) { $savedSearch = new SavedSearch(); $searchModuleBean = new Lead(); $_REQUEST['search_module'] = 'Leads'; $_REQUEST['description'] = 'test description'; $_REQUEST['test_content'] = 'test text'; $expected = array('search_module' => 'Leads', 'description' => 'test description', 'test_content' => 'test text', 'advanced' => true); //execute the method and then retrieve back to verify contents attribute $savedSearch->handleSave('', false, false, $id, $searchModuleBean); $savedSearch->retrieveSavedSearch($id); $this->assertSame($expected, $savedSearch->contents); }
* technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ /********************************************************************************* * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ if (!empty($_REQUEST['saved_search_action'])) { // _pp($_REQUEST); $ss = new SavedSearch(); switch ($_REQUEST['saved_search_action']) { case 'update': // save here $ss->handleSave('', true, false, $_REQUEST['saved_search_select']); break; case 'save': // save here $ss->handleSave('', true, false); break; case 'delete': // delete here $ss->handleDelete($_REQUEST['saved_search_select']); break; } } elseif (!empty($_REQUEST['saved_search_select'])) { // requesting a search here. if (!empty($_REQUEST['searchFormTab'])) { // where is the request from $searchFormTab = $_REQUEST['searchFormTab'];
/** * This test captures the scenario for date_modified field where range search is not enabled */ public function testSaveDateFields() { require_once 'modules/SavedSearch/SavedSearch.php'; $focus = new SavedSearch(); $focus->retrieve($this->saved_search_id); $_REQUEST = unserialize(base64_decode($focus->contents)); unset($_REQUEST['start_range_date_modified_advanced']); unset($_REQUEST['end_range_date_modified_advanced']); unset($_REQUEST['range_date_modified_advanced']); $_REQUEST['date_modified_advanced'] = '07/03/2009'; //Special date :) $mockBean = new Bug42377MockOpportunity(); $focus->handleSave('', false, '', $this->saved_search_id, $mockBean); //Now retrieve what we have saved and test $focus = new SavedSearch(); $focus->retrieve($this->saved_search_id); $formatted_data = unserialize(base64_decode($focus->contents)); $this->assertEquals($formatted_data['date_modified_advanced'], '2009-07-03', "Assert that value is in db format ('2009-07-03')"); //Now test that when we populate the search form, we bring it back to user's date format $focus->retrieveSavedSearch($this->saved_search_id); $focus->populateRequest(); $this->assertEquals($_REQUEST['date_modified_advanced'], '07/03/2009', "Assert that dates in db format were converted back to user's date preference"); //Take this a step further, assume date format now changes, will date be populated correctly? global $current_user; $current_user->setPreference('datef', 'd/m/Y', 0, 'global'); $current_user->save(); //Now test that when we populate the search form, we bring it back to user's date format $focus->retrieveSavedSearch($this->saved_search_id); $focus->populateRequest(); $this->assertEquals($_REQUEST['date_modified_advanced'], '03/07/2009', "Assert that dates in db format were converted back to user's date preference"); }
* technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ /********************************************************************************* * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ if (!empty($_REQUEST['saved_search_action'])) { $ss = new SavedSearch(); switch ($_REQUEST['saved_search_action']) { case 'update': // save here $savedSearchBean = loadBean($_REQUEST['search_module']); $ss->handleSave('', true, false, $_REQUEST['saved_search_select'], $savedSearchBean); break; case 'save': // save here $savedSearchBean = loadBean($_REQUEST['search_module']); $ss->handleSave('', true, false, null, $savedSearchBean); break; case 'delete': // delete here $ss->handleDelete($_REQUEST['saved_search_select']); break; } } elseif (!empty($_REQUEST['saved_search_select'])) { // requesting a search here. if (!empty($_REQUEST['searchFormTab'])) { // where is the request from
public function testSaveNumericFields() { global $current_user; require_once 'modules/SavedSearch/SavedSearch.php'; $focus = new SavedSearch(); $focus->retrieve($this->saved_search_id); $_REQUEST = unserialize(base64_decode($focus->contents)); $_REQUEST['start_range_amount_advanced'] = '$9,500.00'; $_REQUEST['end_range_amount_advanced'] = '$49,500.00'; $mockBean = new Bug42915MockOpportunity(); $focus->handleSave('', false, '', $this->saved_search_id, $mockBean); //Now retrieve what we have saved and test $focus->retrieveSavedSearch($this->saved_search_id); $formatted_data = $focus->contents; $this->assertEquals(9500, $formatted_data['start_range_amount_advanced'], "Assert that value is unformatted value 9500"); $this->assertEquals(49500, $formatted_data['end_range_amount_advanced'], "Assert that value is unformatted value 49500"); $focus->populateRequest(); $this->assertEquals('$9,500.00', $_REQUEST['start_range_amount_advanced'], "Assert that value is formatted value \$9,500.00"); $this->assertEquals('$49,500.00', $_REQUEST['end_range_amount_advanced'], "Assert that value is formatted value \$49,500.00"); $current_user->setPreference('num_grp_sep', '.'); $current_user->setPreference('dec_sep', ','); $current_user->save(); //Force reset on dec_sep and num_grp_sep because the dec_sep and num_grp_sep values are stored as static variables get_number_seperators(true); $focus = new SavedSearch(); $focus->retrieveSavedSearch($this->saved_search_id); $focus->populateRequest(); $this->assertEquals('$9.500,00', $_REQUEST['start_range_amount_advanced'], "Assert that value is formatted value \$9,500.00"); $this->assertEquals('$49.500,00', $_REQUEST['end_range_amount_advanced'], "Assert that value is formatted value \$49,500.00"); //Okay so now what happens if they don't specify currency or separator or decimal values? $_REQUEST['start_range_amount_advanced'] = '9500'; $_REQUEST['end_range_amount_advanced'] = '49500'; //Well then the populated values should be unformatted! $focus->handleSave('', false, '', $this->saved_search_id, $mockBean); $focus->retrieveSavedSearch($this->saved_search_id); $focus->populateRequest(); $this->assertEquals(9500, $_REQUEST['start_range_amount_advanced'], "Assert that value is unformatted value 9500"); $this->assertEquals(49500, $_REQUEST['end_range_amount_advanced'], "Assert that value is unformatted value 49500"); }