Example #1
0
 /**
  * @covers SphinxSearch\Search::showMeta
  */
 public function testShowMeta()
 {
     $mockShow = $this->mockSql->show();
     $mockShow->expects($this->once())->method('show')->with($this->equalTo(Show::SHOW_META));
     $mockShow->expects($this->once())->method('like')->with($this->equalTo('tot'));
     // Assumes prepared statement
     $this->mockResult->expects($this->at(0))->method('rewind')->will($this->returnValue(true));
     $this->mockResult->expects($this->at(1))->method('valid')->will($this->returnValue(true));
     $this->mockResult->expects($this->at(2))->method('current')->will($this->returnValue(['Variable_name' => 'total', 'Value' => '0']));
     $this->mockResult->expects($this->at(3))->method('next');
     $this->mockResult->expects($this->at(4))->method('valid')->will($this->returnValue(false));
     $result = $this->search->showMeta('tot');
     $this->assertInternalType('array', $result);
     $this->assertCount(1, $result);
     $this->assertArrayHasKey('total', $result);
     $this->assertEquals('0', $result['total']);
 }