public function testFilterQueryWithoutValue()
 {
     $query = m::mock('Illuminate\\Database\\Query\\Builder');
     $query->shouldReceive('where')->never();
     $this->config->shouldReceive('getDataModel')->once()->andReturn(m::mock(array('getTable' => 'table')));
     $this->field->shouldReceive('getOption')->twice()->andReturn(false);
     $this->field->filterQuery($query);
 }
 public function testFilterQuery()
 {
     $relationship = m::mock(array('getPlainForeignKey' => '', 'getRelated' => m::mock(array('getTable' => 'table'))));
     $model = m::mock(array('getTable' => 'table', 'getKeyName' => '', 'method' => $relationship));
     $grammar = m::mock('Illuminate\\Database\\Query\\Grammars');
     $grammar->shouldReceive('wrap')->once()->andReturn('');
     $this->config->shouldReceive('getDataModel')->once()->andReturn($model);
     $this->column->shouldReceive('getOption')->times(3)->andReturn('column_name', 'method', 'select')->shouldReceive('getRelationshipWheres')->once()->andReturn('');
     $this->db->shouldReceive('raw')->once()->andReturn('foo')->shouldReceive('getQueryGrammar')->once()->andReturn($grammar);
     $selects = array();
     $this->column->filterQuery($selects);
     $this->assertEquals($selects, array('foo'));
 }
 public function testFilterQueryNoValue()
 {
     $query = m::mock('Illuminate\\Database\\Query\\Builder');
     $query->shouldReceive('where')->never();
     $this->field->shouldReceive('getOption')->once()->andReturn('');
     $this->field->filterQuery($query);
 }
 public function testFilterQueryNoMinOrMax()
 {
     $model = m::mock(array('getTable' => 'table'));
     $query = m::mock('Illuminate\\Database\\Query\\Builder');
     $this->config->shouldReceive('getDataModel')->once()->andReturn($model);
     $this->field->shouldReceive('getOption')->once()->andReturn(false);
     $this->field->filterQuery($query);
 }
 public function testFilterQueryDoesntAddSelect()
 {
     $this->column->shouldReceive('getOption')->once();
     $this->db->shouldReceive('raw')->never()->shouldReceive('getQueryGrammar')->never();
     $selects = array();
     $this->column->filterQuery($selects);
     $this->assertEquals($selects, array());
 }
 public function testFilterQueryWithoutValue()
 {
     $query = m::mock('Illuminate\\Database\\Query\\Builder');
     $query->shouldReceive('whereIn')->never()->shouldReceive('getConnection')->never();
     $this->validator->shouldReceive('isJoined')->never();
     $model = m::mock(array('getTable' => 'table', 'getKeyName' => 'id'));
     $this->config->shouldReceive('getDataModel')->once()->andReturn($model);
     $this->field->shouldReceive('getOption')->times(5)->andReturn(false);
     $selects = array();
     $this->field->filterQuery($query, $selects);
 }