本文整理汇总了PHP中SavedSearch::populateRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP SavedSearch::populateRequest方法的具体用法?PHP SavedSearch::populateRequest怎么用?PHP SavedSearch::populateRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SavedSearch
的用法示例。
在下文中一共展示了SavedSearch::populateRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSaveNumericFields
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");
}
示例2: testSaveDateFields
/**
* 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");
}
示例3: testpopulateRequest
public function testpopulateRequest()
{
$savedSearch = new SavedSearch();
$savedSearch->contents = array('search_module' => 'Accounts', 'description' => 'test text', 'test_content' => 'some content', 'advanced' => true);
$savedSearch->populateRequest();
//verify thhat Request parameters are set
$this->assertEquals('Accounts', $_REQUEST['search_module']);
$this->assertEquals('test text', $_REQUEST['description']);
$this->assertEquals('some content', $_REQUEST['test_content']);
}