コード例 #1
0
 public function testOrderModeException()
 {
     $criteria = new ESphinxSearchCriteria();
     $criteria->sortMode = ESphinxSort::ATTR_DESC;
     try {
         $criteria->getOrders();
         $this->setExpectedException('ESphinxException');
     } catch (Exception $e) {
         $this->assertInstanceOf('ESphinxException', $e);
     }
     try {
         $criteria->cleanOrders();
         $this->setExpectedException('ESphinxException');
     } catch (Exception $e) {
         $this->assertInstanceOf('ESphinxException', $e);
     }
     try {
         $criteria->setOrders(array());
         $this->setExpectedException('ESphinxException');
     } catch (Exception $e) {
         $this->assertInstanceOf('ESphinxException', $e);
     }
     try {
         $criteria->addOrders(array());
         $this->setExpectedException('ESphinxException');
     } catch (Exception $e) {
         $this->assertInstanceOf('ESphinxException', $e);
     }
     try {
         $criteria->addOrder('', '');
         $this->setExpectedException('ESphinxException');
     } catch (Exception $e) {
         $this->assertInstanceOf('ESphinxException', $e);
     }
     try {
         $criteria->sortMode = ESphinxSort::EXTENDED;
         $criteria->getOrders();
         $criteria->cleanOrders();
         $criteria->setOrders(array('a' => 'asc'));
         $criteria->addOrders(array('b' => 'desc'));
         $criteria->addOrder('c', 'ASC');
     } catch (Exception $e) {
         $this->fail('Fail order functions with EXTENDED mode');
     }
 }