/** * Insert data in database * * @return bool */ protected function insert() { $sql = $this->builder->insert($this); $result = Db::query($sql); $this->id = Db::getLastInsertId(); return $result; }
/** * @covers Veles\DataBase\Db::getLastInsertId */ public function testGetLastInsertId() { $adapter = $this->getMockBuilder('\\Veles\\DataBase\\Adapters\\PdoAdapter')->setMethods(['getLastInsertId'])->getMock(); $adapter->expects($this->once())->method('getLastInsertId')->willReturn($adapter); Db::setAdapter($adapter); Db::getLastInsertId(); }