Skip to content
Permalink
Browse files

Add test for selecting paginated results, order by calculated column

  • Loading branch information...
Mike Fellows Mike Fellows
Mike Fellows authored and Mike Fellows committed Jul 26, 2017
1 parent 74bb873 commit 8fb97c5bdfda592cc615717ab9059aec2d9f81c3
Showing with 30 additions and 0 deletions.
  1. +30 −0 tests/TestCase/Database/QueryTest.php
@@ -2247,6 +2247,36 @@ public function testSelectPage()
$this->assertEquals(25, $query->clause('offset'));
}
/**
* Test selecting rows using the page() method and ordering the results
* by a calculated column.
*
* @return void
*/
public function testSelectPageWithOrder()
{
$this->loadFixtures('Comments');
$query = new Query($this->connection);
$result = $query
->select([
'id',
'ids_added' => $query->newExpr()->add('(user_id + article_id)')
])
->from('comments')
->order(['ids_added' => 'asc'])
->limit(2)
->page(3)
->execute();
$this->assertCount(2, $result);
$this->assertEquals(
[
['id' => '6', 'ids_added' => '4'],
['id' => '2', 'ids_added' => '5']
],
$result->fetchAll('assoc')
);
}
/**
* Tests that Query objects can be included inside the select clause
* and be used as a normal field, including binding any passed parameter

0 comments on commit 8fb97c5

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.