public function testFilters() { $criteria = new ESphinxSearchCriteria(); try { $criteria->addFilters(''); $this->setExpectedException('ESphinxException'); } catch (Exception $e) { $this->assertInstanceOf('ESphinxException', $e); } try { $criteria->addFilters(array()); $this->setExpectedException('ESphinxException'); } catch (Exception $e) { $this->assertInstanceOf('ESphinxException', $e); } try { $criteria->addFilters('', ''); $this->setExpectedException('ESphinxException'); } catch (Exception $e) { $this->assertInstanceOf('ESphinxException', $e); } // add attribute $criteria->addFilter('attribute', 10); $this->assertEquals($criteria->getFilters(), array(array('attribute' => 'attribute', 'value' => array(10), 'exclude' => false))); // clean $criteria->cleanFilters(); $this->assertEquals($criteria->getFilters(), array()); // adds value with exclude $criteria->addFilter('attribute', array(10, 20), true); $this->assertEquals($criteria->getFilters(), array(array('attribute' => 'attribute', 'value' => array(10, 20), 'exclude' => true))); // clean all $criteria->cleanFilters(); $this->assertEquals($criteria->getFilters(), array()); // add two filters $criteria->addFilters(array(array('a1', 11), array('a2', 22, 'exclude' => 1))); $this->assertEquals($criteria->getFilters(), array(array('attribute' => 'a1', 'value' => array(11), 'exclude' => false), array('attribute' => 'a2', 'value' => array(22), 'exclude' => true))); // установка новых значений $criteria->setFilters(array(array('a22', 'some-value'))); $this->assertEquals($criteria->getFilters(), array(array('attribute' => 'a22', 'value' => array('some-value'), 'exclude' => false))); }