Skip to content

Commit fa91dad

Browse files
authored
Added tests for paginateRaw (#575)
Co-authored-by: Bert Kooij <[email protected]>
1 parent f526772 commit fa91dad

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/Feature/BuilderTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,30 @@ public function test_it_can_paginate_with_custom_query_callback()
6363
$this->assertSame(15, $paginator->perPage());
6464
}
6565

66+
public function test_it_can_paginate_raw_without_custom_query_callback()
67+
{
68+
$this->prepareScoutSearchMockUsing('Laravel');
69+
70+
$paginator = SearchableUserModel::search('Laravel')->paginateRaw();
71+
72+
$this->assertSame(50, $paginator->total());
73+
$this->assertSame(4, $paginator->lastPage());
74+
$this->assertSame(15, $paginator->perPage());
75+
}
76+
77+
public function test_it_can_paginate_raw_with_custom_query_callback()
78+
{
79+
$this->prepareScoutSearchMockUsing('Laravel');
80+
81+
$paginator = SearchableUserModel::search('Laravel')->query(function ($builder) {
82+
return $builder->where('id', '<', 11);
83+
})->paginateRaw();
84+
85+
$this->assertSame(10, $paginator->total());
86+
$this->assertSame(1, $paginator->lastPage());
87+
$this->assertSame(15, $paginator->perPage());
88+
}
89+
6690
protected function prepareScoutSearchMockUsing($searchQuery)
6791
{
6892
$engine = m::mock('MeiliSearch\Client');

0 commit comments

Comments
 (0)