-
-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathSelection.order().phpt
More file actions
42 lines (31 loc) · 990 Bytes
/
Selection.order().phpt
File metadata and controls
42 lines (31 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* Test: Nette\Database\Table: Search and order items.
* @dataProvider? ../databases.ini
*/
use Tester\Assert;
require __DIR__ . '/../connect.inc.php'; // create $connection
Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../files/{$driverName}-nette_test1.sql");
test(function() use ($context) {
$apps = array();
$selection = $context->table('book')->where('title LIKE ?', '%t%')->order('title DESC')->limit(3);
foreach ($selection as $book) { // SELECT * FROM `book` WHERE (`title` LIKE ?) ORDER BY `title` DESC LIMIT 3
$apps[] = $book->title;
}
Assert::same(array(
'Nette',
'1001 tipu a triku pro PHP',
), $apps);
});
test(function() use ($context) {
$apps = array();
$selection = $context->table('book')->order('title DESC')->resetOrder()->limit(3);
foreach ($selection as $book) { // SELECT * FROM `book` LIMIT 3
$apps[] = $book->title;
}
Assert::same(array(
'1001 tipu a triku pro PHP',
'JUSH',
'Nette',
), $apps);
});