Skip to content

Commit 2dad83b

Browse files
committed
Fix for paginate tests.
1 parent 8107f47 commit 2dad83b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

tests/functional/SearchTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,6 @@ public function testSearchWithPaginate()
9999
$query = Search::query('laser pointer', ['name', 'description']);
100100
$founded = $query->paginate(2, 2);
101101

102-
$this->assertEquals('broken pointer', $founded[0]->name);
102+
$this->assertCount(1, $founded);
103103
}
104104
}

tests/unit/Query/BuilderTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php namespace tests\unit\Query;
22

3+
use Illuminate\Database\Eloquent\Collection;
34
use tests\TestCase;
45

5-
use Illuminate\Pagination\Paginator;
66
use Mockery as m;
77
use ZendSearch\Lucene\Search\Query\Boolean;
88

@@ -124,19 +124,27 @@ public function testAddFilter()
124124
public function testPaginate()
125125
{
126126
$query = $this->constructor->query('test');
127-
$this->runner->shouldReceive('models')->with($this->query, ['limit' => 2, 'offset' => 0])->andReturn([1, 2])->byDefault();
127+
$this->runner->shouldReceive('models')
128+
->with($this->query, ['limit' => 2, 'offset' => 0])
129+
->andReturn(Collection::make([1, 2]))->byDefault();
128130

129131
$expected = App::make('paginator')->make([1, 2], 3, 2);
130132
$actual = $query->paginate(2);
131133

132134
$this->assertEquals($expected, $actual);
133135

134-
$this->runner->shouldReceive('models')->with($this->query, ['limit' => 2, 'offset' => 2])->andReturn([1, 2])->byDefault();
136+
$this->runner->shouldReceive('models')
137+
->with($this->query, ['limit' => 2, 'offset' => 2])
138+
->andReturn(Collection::make([1, 2]))->byDefault();
139+
135140
$actual = $query->paginate(2, 2);
136141

137142
$this->assertEquals($expected, $actual);
138143

139-
$this->runner->shouldReceive('models')->with($this->query, ['limit' => 2, 'offset' => 2])->andReturn([1, 2])->byDefault();
144+
$this->runner->shouldReceive('models')
145+
->with($this->query, ['limit' => 2, 'offset' => 2])
146+
->andReturn(Collection::make([1, 2]))->byDefault();
147+
140148
$actual = $query->paginate(2, function () { return 2; });
141149

142150
$this->assertEquals($expected, $actual);

0 commit comments

Comments
 (0)