Example #1
0
 /**
  * @covers SphinxSearch\Db\Sql\Sql::update
  */
 public function testUpdate()
 {
     $update = $this->sql->update();
     $this->assertInstanceOf('\\Zend\\Db\\Sql\\Update', $update);
     $this->assertSame('foo', $update->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->update('bar');
 }
Example #2
0
 /**
  * @covers SphinxSearch\Indexer::update
  * @covers SphinxSearch\Indexer::updateWith
  */
 public function testUpdate()
 {
     $mockUpdate = $this->mockSql->update('foo');
     $mockUpdate->expects($this->once())->method('where')->with($this->equalTo('id = 2'));
     $affectedRows = $this->indexer->update('foo', ['foo' => 'bar'], 'id = 2');
     $this->assertEquals(5, $affectedRows);
     // Where with closure
     $mockUpdate = $this->mockSql->update('foo');
     $this->indexer->update('foo', ['foo' => 'bar'], function ($update) use($mockUpdate) {
         IndexerTest::assertSame($mockUpdate, $update);
     });
     $this->assertEquals(5, $affectedRows);
 }