fixing an sql query causing problems in the map loading script.
[cxgn-corelibs.git] / t / CXGN / DB / object.t
blob6b30dbcb9eba8e485cd82f329b574e4fe586cabf
2 =head1 NAME
4 object.t - a test script for the CXGN::DB::Object class.
6 =head1 AUTHOR
8 Lukas Mueller
10 =cut
12 use strict;
14 use Test::More tests => 9;
15 use Test::Warn;
17 BEGIN {
19     use_ok("CXGN::DB::Connection");
20     use_ok("CXGN::DB::Object");
24 my $dbh = CXGN::DB::Connection->new();
26 my $dbo = CXGN::DB::Object->new($dbh);
27 isnt( $dbo,          undef, "object not undef check" );
28 isnt( $dbo->get_dbh, undef, "dbh in object not undef check" );
29 can_ok( $dbo->get_dbh, 'selectall_arrayref', 'prepare' );
31 warning_is {
32     CXGN::DB::Object->new( $dbh->get_actual_dbh )
33 } undef, 'does not warn for an actual dbh';
35 my $tdbo = TestDBObject->new($dbh);
36 isa_ok( $tdbo->get_dbh, "CXGN::DB::Connection" );
38 my $so = DBIxSchemaObject->connect(
39     sub { return CXGN::DB::Connection->new()->get_actual_dbh(); } );
41 my $tso = TestSchemaObject->new($so);
43 ok( $tso->get_schema()->isa("DBIx::Class"),
44     "Test schema object accessor test" );
46 is( $tso->get_dbh()->isa("DBI::db"), 1,
47     "Test schema object dbh accessor test" );
49 package TestDBObject;
51 use base qw | CXGN::DB::Object |;
53 sub new {
54     my $class = shift;
55     my $dbh   = shift;
57     my $self = $class->SUPER::new($dbh);
59     return $self;
62 package TestSchemaObject;
64 use base qw | CXGN::DB::Object |;
66 sub new {
67     my $class  = shift;
68     my $schema = shift;
70     my $self = $class->SUPER::new($schema);
72     return $self;
75 package DBIxSchemaObject;
77 use base qw | DBIx::Class::Schema |;
79 __PACKAGE__->load_components( "PK::Auto", "Core" );