Ejemplo n.º 1
0
 public function setUp()
 {
     if (file_exists('custom/modules/Opportunities/metadata/SearchFields.php')) {
         $this->hasExistingCustomSearchFields = true;
         copy('custom/modules/Opportunities/metadata/SearchFields.php', 'custom/modules/Opportunities/metadata/SearchFields.php.bak');
         unlink('custom/modules/Opportunities/metadata/SearchFields.php');
     } else {
         if (!file_exists('custom/modules/Opportunities/metadata')) {
             mkdir_recursive('custom/modules/Opportunities/metadata');
         }
     }
     //Setup Opportunities module and date_closed field
     $_REQUEST['view_module'] = 'Opportunities';
     $_REQUEST['name'] = 'date_closed';
     $templateDate = new TemplateDate();
     $templateDate->enable_range_search = true;
     $templateDate->populateFromPost();
     include 'custom/modules/Opportunities/metadata/SearchFields.php';
     //Prepare SearchForm
     $seed = new Opportunity();
     $module = 'Opportunities';
     $this->searchForm = new SearchForm($seed, $module);
     $this->searchForm->searchFields = array('range_date_closed' => array('query_type' => 'default', 'enable_range_search' => 1, 'is_date_field' => 1, 'value' => '[this_year]', 'operator' => 'this_year'), 'start_range_date_closed' => array('query_type' => 'default', 'enable_range_search' => 1, 'is_date_field' => 1), 'end_range_date_closed' => array('query_type' => 'default', 'enable_range_search' => 1, 'is_date_field' => 1), 'range_amount' => array('query_type' => 'default', 'enable_range_search' => true), 'start_range_amount' => array('query_type' => 'default', 'enable_range_search' => true), 'end_range_amount' => array('query_type' => 'default', 'enable_range_search' => true));
     $this->originalDbType = $GLOBALS['db']->dbType;
 }
Ejemplo n.º 2
0
 public function testEnableRangeSearchDate()
 {
     $_REQUEST['view_module'] = 'Opportunities';
     $_REQUEST['name'] = 'date_closed';
     $templateDate = new TemplateDate();
     $templateDate->enable_range_search = true;
     $templateDate->populateFromPost();
     $this->assertTrue(file_exists('custom/modules/Opportunities/metadata/SearchFields.php'));
     include 'custom/modules/Opportunities/metadata/SearchFields.php';
     $this->assertTrue(isset($searchFields['Opportunities']['range_date_closed']));
     $this->assertTrue(isset($searchFields['Opportunities']['start_range_date_closed']));
     $this->assertTrue(isset($searchFields['Opportunities']['end_range_date_closed']));
     $this->assertTrue(isset($searchFields['Opportunities']['range_date_closed']['is_date_field']));
     $this->assertTrue(isset($searchFields['Opportunities']['start_range_date_closed']['is_date_field']));
     $this->assertTrue(isset($searchFields['Opportunities']['end_range_date_closed']['is_date_field']));
 }