Beispiel #1
0
 /**
  * @covers SphinxSearch\Db\Sql\Sql::replace
  */
 public function testReplace()
 {
     $insert = $this->sql->replace();
     $this->assertInstanceOf('\\SphinxSearch\\Db\\Sql\\Replace', $insert);
     $this->assertSame('foo', $insert->getRawState('table'));
     $this->setExpectedException('\\SphinxSearch\\Db\\Sql\\Exception\\InvalidArgumentException', 'This Sql object is intended to work with only the table "foo" provided at construction time.');
     $this->sql->replace('bar');
 }
Beispiel #2
0
 /**
  * @covers SphinxSearch\Indexer::insert
  * @covers SphinxSearch\Indexer::insertWith
  */
 public function testInsert()
 {
     $mockInsert = $this->mockSql->insert('foo');
     $mockInsert->expects($this->once())->method('prepareStatement')->with($this->mockAdapter);
     $mockInsert->expects($this->once())->method('values')->with($this->equalTo(['foo' => 'bar']));
     $affectedRows = $this->indexer->insert('foo', ['foo' => 'bar']);
     $this->assertEquals(5, $affectedRows);
     // Testing replace mode
     $mockReplace = $this->mockSql->replace('foo');
     $mockReplace->expects($this->once())->method('prepareStatement')->with($this->mockAdapter);
     $mockReplace->expects($this->once())->method('values')->with($this->equalTo(['foo' => 'bar']));
     $affectedRows = $this->indexer->insert('foo', ['foo' => 'bar'], true);
     $this->assertEquals(5, $affectedRows);
 }