4 use CXGN
::Class
::MethodMaker
[
12 {-type
=> "CXGN::DB::Connection",
13 -forward
=> [qw
/prepare execute/]
16 qw
/ -static static_var /,
20 sub new
{ bless {}, shift }
24 use Test
::More tests
=> 13;
26 ok
(defined(&Foo
::these
), "Foo method these() created");
29 ok
($foo->these(), "Setter for these() works");
30 ok
($foo->these_isset(), "these_isset() is correct");
32 ok
(!$foo->these_isset(), "these_reset() affects these_isset() properly");
33 ok
(!defined($foo->these()), "these_reset() also delete value properly");
35 ok
($foo->these_isset(), "these_isset() works after setting");
36 is
($foo->methods(), 3, "Default option worked");
38 use CXGN
::DB
::Connection
{ verbose
=> 0 };
39 my $dbh = CXGN
::DB
::Connection
->new();
44 diag
("Expected error: ". $@
);
45 ok
($@
, "Setting dbh() to non-CXGN::DB::Connection type failed, as it should");
50 ok
(!$@
, "Setting dbh to CXGN::DB::Connection object successful");
52 ok
(defined(&Foo
::prepare
), "Method prepare() exists on Foo");
54 my $sql = "SELECT COUNT(*) FROM sgn_people.sp_person";
55 diag
("Preparing SQL: ". $sql);
56 my $sth = $foo->prepare($sql);
58 my ($count) = $sth->fetchrow_array();
60 ok
($count, "Foo correctly forwards prepare() to its dbh() and gets a result: $count");
63 is
(Foo
->static_var(), 3, "Static scalar set, tested on package");
65 is
($foo2->static_var(), 3, "Static scalar set, tested on different instance");