5 use Test
::More tests
=> 7;
8 use SGN
::Test
::WWW
::Mechanize
;
10 use CXGN
::Biosource
::Schema
;
12 my $mech = SGN
::Test
::WWW
::Mechanize
->new;
14 ## First take variables for the test from the database ##
16 my @schema_list = ('biosource', 'metadata', 'public');
17 my $schema_list = join(',', @schema_list);
18 my $set_path = "SET search_path TO $schema_list";
20 my $dbh = $mech->context()->dbc()->dbh();
22 my $bs_schema = CXGN
::Biosource
::Schema
->connect( sub { $dbh },
23 {on_connect_do
=> $set_path} );
26 ## WWW.SAMPLE TEST ###
28 my ($first_sample_row) = $bs_schema->resultset('BsSample')
31 order_by
=> {-asc
=> 'sample_id'},
36 ## Now it will test the expected sample web-page if there is at least one row
37 ## in the database. If not, it will test the error page
39 if (defined $first_sample_row) {
41 my $first_sample_id = $first_sample_row->get_column('sample_id');
42 my $first_sample_name = $first_sample_row->get_column('sample_name');
44 $mech->get_ok("/biosource/sample.pl?id=$first_sample_id");
45 $mech->content_contains( $first_sample_name );
46 is
( $mech->status, 200 );
47 $mech->content_unlike( qr/error/i );
49 $mech->get_ok("/biosource/sample.pl?name=$first_sample_name");
50 $mech->content_contains( $first_sample_name );
51 $mech->content_unlike( qr/error/i );