Example #1
0
 /**
  * @covers SphinxSearch\Db\Sql\Sql::insert
  */
 public function testInsert()
 {
     $insert = $this->sql->insert();
     $this->assertInstanceOf('\\SphinxSearch\\Db\\Sql\\Insert', $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->insert('bar');
 }
Example #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);
 }