/**
  * Tests that by calling compile internal iteration operations are not done
  * more than once
  *
  * @return void
  */
 public function testCompile()
 {
     $items = ['a' => 1, 'b' => 2, 'c' => 3];
     $collection = new Collection($items);
     $callable = $this->getMock('stdClass', ['__invoke']);
     $callable->expects($this->at(0))->method('__invoke')->with(1, 'a')->will($this->returnValue(4));
     $callable->expects($this->at(1))->method('__invoke')->with(2, 'b')->will($this->returnValue(5));
     $callable->expects($this->at(2))->method('__invoke')->with(3, 'c')->will($this->returnValue(6));
     $compiled = $collection->map($callable)->compile();
     $this->assertEquals(['a' => 4, 'b' => 5, 'c' => 6], $compiled->toArray());
     $this->assertEquals(['a' => 4, 'b' => 5, 'c' => 6], $compiled->toArray());
 }
 /**
  * Set an override for a column, columns or restore all to default
  * 
  * Pass CRUDDATA_DEFAULT_OVERRIDES (FALSE) to restore to default types for all columns
  * Pass string_name, string_value to override one column
  * Pass [
  *		string_name => string_value,
  * 		string_name => string_value
  * ] for multiple overrides at once
  * 
  * @param array|string|boolean $override
  * @param string $type
  * @return array
  */
 public function override($override = NULL, $type = 'string')
 {
     if ($override === CRUDDATA_DEFAULT_OVERRIDES) {
         $this->_clearOverrides();
     } elseif (is_string($override)) {
         $this->_columns[$override]['type'] = $type;
     } elseif (is_array($override)) {
         foreach ($override as $column => $type) {
             $this->_columns[$column]['type'] = $type;
         }
     }
     $columns = new Collection($this->columns());
     $overrides = [];
     return $columns->map(function ($value, $key) use(&$overrides) {
         return $overrides[$key] = ['type' => $value['type']];
     })->toArray();
 }