Add a basic search clause to the query.
public query ( $value, $field = '*', array $options = [] ) | ||
$value | ||
$field | ||
$options | array | - required : should match (boolean, true by default) - prohibited : should not match (boolean, false by default) - phrase : phrase match (boolean, true by default) - proximity : value of distance between words (unsigned integer) - fuzzy : value of fuzzy(float, 0 ... 1) |
public function testPaginate() { $models = m::mock(LazyCollection::make([])); $models->shouldReceive('slice')->with(0, 2)->andReturn($sliced = m::mock(LazyCollection::make([]))); $sliced->shouldReceive('reload')->andReturn(Collection::make([1, 2])); $query = $this->constructor->query('test'); $this->runner->shouldReceive('models')->with($this->query)->andReturn($models); $expected = new Paginator([1, 2], 3, 2); $actual = $query->paginate(2); $this->assertEquals($expected, $actual); $models->shouldReceive('slice')->with(2, 2)->andReturn($sliced); $this->runner->shouldReceive('models')->with($this->query)->andReturn($models); $actual = $query->paginate(2, 2); $this->assertEquals($expected, $actual); }
public function testPaginate() { $query = $this->constructor->query('test'); $this->runner->shouldReceive('models')->with($this->query, ['limit' => 2, 'offset' => 0])->andReturn([1, 2])->byDefault(); $expected = new Paginator([1, 2], 3, 2); $actual = $query->paginate(2); $this->assertEquals($expected, $actual); $this->runner->shouldReceive('models')->with($this->query, ['limit' => 2, 'offset' => 2])->andReturn([1, 2])->byDefault(); $actual = $query->paginate(2, 2); $this->assertEquals($expected, $actual); $this->runner->shouldReceive('models')->with($this->query, ['limit' => 2, 'offset' => 2])->andReturn([1, 2])->byDefault(); $actual = $query->paginate(2, function () { return 2; }); $this->assertEquals($expected, $actual); }