root/Class-DBI-AbstractSearch/trunk/t/02_order.t

Revision 1421 (checked in by miyagawa, 17 years ago)

0.05

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 use strict;
2 use Test::More;
3
4 BEGIN {
5     eval "use DBD::SQLite";
6     plan $@ ? (skip_all => 'needs DND::SQLite for testing')
7         : (tests => 2);
8 }
9
10 use DBI;
11
12 my $DB  = "t/testdb";
13 my @DSN = ("dbi:SQLite:dbname=$DB", '', '', { AutoCommit => 1 });
14 DBI->connect(@DSN)->do(<<SQL);
15 CREATE TABLE film (id INTEGER NOT NULL PRIMARY KEY, title VARCHAR(32))
16 SQL
17     ;
18
19 package Film;
20
21 use base qw(Class::DBI);
22 __PACKAGE__->set_db(Main => @DSN);
23 __PACKAGE__->table('film');
24 __PACKAGE__->columns(Primary => qw(id));
25 __PACKAGE__->columns(All => qw(title));
26
27 use Class::DBI::AbstractSearch;
28
29 package main;
30 for my $i (1..50) {
31     Film->create({
32         title => "title $i",
33     });
34 }
35
36 {
37     my @films = Film->search_where({title => [ "title 10", "title 20" ]},
38                                    {order_by =>["title DESC"]});
39     is @films, 2, "films return 2";
40
41     cmp_ok($films[0]->title(),"eq","title 20","Title is title 20");
42 }
43
44 END { unlink $DB if -e $DB }
45
Note: See TracBrowser for help on using the browser.