Beispiel #1
0
 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);
 }
Beispiel #2
0
 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));
 }
Beispiel #3
0
 /**
  * @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);
 }
Beispiel #4
0
 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));
 }
Beispiel #5
0
 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();
 }