6 use SGN::Test qw/validate_urls/;
9 use SGN::Test::WWW::Mechanize;
10 use CXGN::Biosource::Schema;
16 my $mech = SGN::Test::WWW::Mechanize->new;
18 ## This test are local test, so it will use the with_test_level function
20 $mech->with_test_level(
23 ## First take variables for the test from the database ##
25 my @schema_list = ( 'biosource', 'metadata', 'public' );
26 my $schema_list = join( ',', @schema_list );
27 my $set_path = "SET search_path TO $schema_list";
29 my $dbh = $mech->context()->dbc()->dbh();
31 my $bs_schema = CXGN::Biosource::Schema->connect( sub { $dbh },
32 { on_connect_do => $set_path } );
34 ## WWW.SAMPLE TEST ###
36 my ($first_sample_row) = $bs_schema->resultset('BsSample')->search(
39 order_by => { -asc => 'sample_id' },
44 ## Now it will test the expected sample web-page if there is at least one row
45 ## in the database. If not, it will test the error page
47 if ( defined $first_sample_row ) {
49 my $first_sample_id = $first_sample_row->get_column('sample_id');
50 my $first_sample_name =
51 $first_sample_row->get_column('sample_name');
53 $urls{'biosource sample page'} =
54 "/biosource/sample.pl?id=$first_sample_id";
55 $urls{'biosource sample page'} =
56 "/biosource/sample.pl?name=$first_sample_name";
60 validate_urls( \%urls, $ENV{ITERATIONS} || 1 );