Skip to content

Commit

Permalink
Merge 8577ca8 into 98bc2f5
Browse files Browse the repository at this point in the history
  • Loading branch information
Yahatix committed Mar 13, 2020
2 parents 98bc2f5 + 8577ca8 commit de09068
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Jenssegers/Mongodb/Query/Builder.php
Expand Up @@ -382,7 +382,7 @@ public function getFresh($columns = [])
$options['skip'] = $this->offset;
}
if ($this->limit) {
$options['limit'] = $this->limit;
$options['limit'] = (int) $this->limit;
}
if ($this->hint) {
$options['hint'] = $this->hint;
Expand Down
14 changes: 14 additions & 0 deletions tests/QueryTest.php
Expand Up @@ -327,6 +327,20 @@ public function testPaginate(): void
$this->assertEquals(1, $results->currentPage());
}

public function testThatPaginateCastsPerPageParameter()
{
$results = User::paginate('2');
$this->assertEquals(2, $results->count());
$this->assertNotNull($results->first()->title);
$this->assertEquals(9, $results->total());

$results = User::paginate('2', ['name', 'age']);
$this->assertEquals(2, $results->count());
$this->assertNull($results->first()->title);
$this->assertEquals(9, $results->total());
$this->assertEquals(1, $results->currentPage());
}

public function testUpdate(): void
{
$this->assertEquals(1, User::where(['name' => 'John Doe'])->update(['name' => 'Jim Morrison']));
Expand Down

0 comments on commit de09068

Please sign in to comment.