MockQueryResultIterator

Class MockQueryResultIterator mock for QueryResultIterator.

Defined (1)

The class is defined in the following location(s).

/phpunit/MockQueryResultIterator.php  
  1. class MockQueryResultIterator extends CFDBAbstractQueryResultsIterator { 
  2.  
  3. var $data; 
  4.  
  5. var $columns; 
  6.  
  7. function __construct(&$data) { 
  8. $this->data =& $data; 
  9. if (count($data) > 0) { 
  10. $this->columns = array_keys($data[0]); 
  11.  
  12. /** 
  13. * Execute the query 
  14. * @param $sql string query 
  15. * @param $queryOptions array associative 
  16. * @return void 
  17. */ 
  18. public function queryDataSource(&$sql, $queryOptions) { 
  19. // Do nothing. $data injected. 
  20.  
  21. /** 
  22. * Get the next row from query results 
  23. * @return array associative 
  24. */ 
  25. public function fetchRow() { 
  26. $row = array_shift($this->data); 
  27. return $row; 
  28.  
  29. /** 
  30. * If you do not iterate over all the rows returned, be sure to call this function 
  31. * on all remaining rows to free resources. 
  32. * @return void 
  33. */ 
  34. public function freeResult() {