summaryrefslogtreecommitdiffstats
path: root/t/search.t
blob: 2f6bb840895c6d9ef77dcdff2760618af69459d2 (plain)
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
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use FindBin;
use Test::More;
use DBI;
use lib "$FindBin::Bin/lib";
use lib "$FindBin::Bin/../lib";

BEGIN 
{
  eval { require DBD::CSV; }
    or plan skip_all => 
    "DBD::CSV is needed for this test";

  plan tests => 9;

  unlink('foo_table') if ( -e 'foo_table' );
  my $dbh = DBI->connect('DBI:CSV:f_dir=./') or die $DBI::errstr;
  $dbh->do('create table foo_table (id INTEGER, name CHAR(255), password CHAR(255), email CHAR(255))') or $dbh->errstr;
  $dbh->disconnect();

  use_ok('Foo');
}

my $obj = Foo->find_or_create( id => 1, name => 'jason', password => 'pass', email => 'woodwardj@jaos.org' );
isa_ok($obj,'Foo');

ok(Foo->search(name => 'jason') > 0,'search returns array');
ok(Foo->search(name => 'jason',{ order_by => 'id'}) > 0,'search with order_by returns array');
ok(Foo->search_where("name = 'jason'") > 0,'search returns array');
ok(Foo->search_like(name => 'j%') > 0,'search_like returns array');
ok(Foo->search_ilike() > 0,'search_ilike returns array');
ok(Foo->search_or_like() > 0,'search_or_like returns array');
ok(Foo->search_or_ilike() > 0,'search_or_ilike returns array');

END
{
  unlink('foo_table');
}