public function testQueryFilter() { $model = new Kwf_Model_FnF(array('data' => array(array('id' => 1, 'value' => 'foo'), array('id' => 2, 'value' => 'foobar'), array('id' => 3, 'value' => 'bar')))); $filter = new Kwf_Controller_Action_Auto_Filter_Query(); $filter->setModel($model); $filter->setFieldName('value'); $select = $filter->formatSelect($model->select()); $this->assertEquals(3, $model->countRows($select)); $select = $filter->formatSelect($model->select(), array('query_value' => 'foo')); $this->assertEquals(1, $model->countRows($select)); $select = $filter->formatSelect($model->select(), array('query_value' => 'foobar')); $this->assertEquals(1, $model->countRows($select)); $select = $filter->formatSelect($model->select(), array('query_value' => 'xxx')); $this->assertEquals(0, $model->countRows($select)); $filter->setSelectType(Kwf_Controller_Action_Auto_Filter_Query::SELECT_TYPE_CONTAINS); $select = $filter->formatSelect($model->select(), array('query_value' => 'foo')); $this->assertEquals(2, $model->countRows($select)); $select = $filter->formatSelect($model->select(), array('query_value' => 'bar')); $this->assertEquals(2, $model->countRows($select)); $select = $filter->formatSelect($model->select(), array('query_value' => 'foobar')); $this->assertEquals(1, $model->countRows($select)); }
protected function _init() { parent::_init(); $this->_mandatoryProperties['data'] = null; }
protected function _init() { parent::_init(); $this->setSelectType(Kwf_Controller_Action_Auto_Filter_Query::SELECT_TYPE_CONTAINS); }