public function testCheckForInspectedRowLimitOnSuccess() { $bigResult = $this->getMockBuilder(BigResult::class)->setConstructorArgs([$this->adapter])->setMethods(['getInspectedRows'])->getMock(); $bigResult->expects($this->any())->method('getInspectedRows')->will($this->returnValue(5)); $this->adapter->expects($this->once())->method('query'); $bigResult->query('SELECT', [], 10); }
public function testRemove() { $pdoStatement = $this->getMock(\PDOStatement::class); $pdoStatement->expects($this->any())->method('rowCount')->will($this->returnValue(1)); $this->adapter->expects($this->any())->method('query')->will($this->returnValue($pdoStatement)); $scheduler = new DbScheduler($this->adapter); $this->assertTrue($scheduler->remove(234)); }
/** * @dataProvider deleteDataProvider */ public function testDelete($expectedSql, $table, $where, $bind) { $executeArgs = is_null($bind) ? [] : $bind; // Returned stmt will have rowCount called $pdoStatement = $this->getMock('\\PDOStatement'); $pdoStatement->expects($this->once())->method('rowCount'); // Query should be called with the SQL and bind $this->adapter->expects($this->once())->method('query')->with($expectedSql, $executeArgs)->will($this->returnValue($pdoStatement)); $result = !is_null($where) ? !is_null($bind) ? $this->crud->delete($table, $where, $bind) : $this->crud->delete($table, $where) : $this->crud->delete($table); }
public function testClearStats() { $this->adapter->expects($this->any())->method('execute')->will($this->returnValue(1)); $inserter = new BulkInsert($this->adapter, 'table', ['field1'], []); $inserter->add(['field1' => 'foo']); $expected = ['total' => 0, 'inserted' => 0, 'updated' => 0, 'pending' => 0]; $this->assertNotEquals($expected, $inserter->fetchStats(true)); $inserter->clearStats(); $this->assertEquals($expected, $inserter->fetchStats(true)); }
public function testGetPlanDoesExplain() { $pdoStatement = $this->getMock(\PDOStatement::class); $this->adapter->expects($this->once())->method('query')->with($this->stringContains('EXPLAIN', true))->will($this->returnValue($pdoStatement)); (new QueryPlanner($this->adapter, 'SELECT'))->getPlan(); }