public function testGetCustomFieldDataByPartialName()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $values = array('Automotive', 'Adult Entertainment', 'Financial Services', 'Mercenaries & Armaments', 'autam');
     $industryFieldData = CustomFieldData::getByName('testData');
     $industryFieldData->defaultValue = $values[0];
     $industryFieldData->serializedData = serialize($values);
     $this->assertTrue($industryFieldData->save());
     $results = ModelAutoCompleteUtil::getCustomFieldDataByPartialName('testData', 'a');
     $this->assertEquals(3, count($results));
     $results = ModelAutoCompleteUtil::getCustomFieldDataByPartialName('testData', 'Au');
     $this->assertEquals(2, count($results));
     $results = ModelAutoCompleteUtil::getCustomFieldDataByPartialName('testData', 'Mer');
     $this->assertEquals(1, count($results));
     $results = ModelAutoCompleteUtil::getCustomFieldDataByPartialName('testData', 'sat');
     $this->assertEquals(0, count($results));
     $results = ModelAutoCompleteUtil::getCustomFieldDataByPartialName('testData', 'Aux');
     $this->assertEquals(0, count($results));
 }
 /**
  * Given a name of a customFieldData object and a term to search on return a JSON encoded
  * array of autocomplete search results.
  * @param string $name - Name of CustomFieldData
  * @param string $term - term to search on
  */
 public function actionAutoCompleteCustomFieldData($name, $term)
 {
     assert('is_string($name)');
     assert('is_string($term)');
     $autoCompleteResults = ModelAutoCompleteUtil::getCustomFieldDataByPartialName($name, $term);
     if (count($autoCompleteResults) == 0) {
         $data = Zurmo::t('Core', 'No results found');
         $autoCompleteResults[] = array('id' => '', 'name' => $data);
     }
     echo CJSON::encode($autoCompleteResults);
 }