public function testGetByPartialName()
 {
     //Search by code expecting multiple results
     $data = CurrencyCodeAutoCompleteUtil::getByPartialCodeOrName('EU');
     $compareData = array(array('value' => 'EUR', 'label' => 'EUR Euro Member Countries'), array('value' => 'MDL', 'label' => 'MDL Moldova Leu'), array('value' => 'RON', 'label' => 'RON Romania New Leu'));
     $this->assertEquals($compareData, $data);
     //Search by code expecting multiple results, but lowercase. Should produce same results.
     $data = CurrencyCodeAutoCompleteUtil::getByPartialCodeOrName('eu');
     $this->assertEquals($compareData, $data);
     //Search by invalid code or name.
     $data = CurrencyCodeAutoCompleteUtil::getByPartialCodeOrName('exsur');
     $this->assertEquals(array(), $data);
     //Search by valid partial name.
     $compareData = array(array('value' => 'FKP', 'label' => 'FKP Falkland Islands (Malvinas) Pound'));
     $data = CurrencyCodeAutoCompleteUtil::getByPartialCodeOrName('falk');
     $this->assertEquals($compareData, $data);
 }
예제 #2
0
 public function actionAutoComplete($term)
 {
     $autoCompleteResults = CurrencyCodeAutoCompleteUtil::getByPartialCodeOrName($term);
     echo CJSON::encode($autoCompleteResults);
 }