Merge branch 'topic/image_upload'
[sgn.git] / t / integration / biosource.t
blob7dceb64b1c3f0fb64da462033c3b1175c71e77b2
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 use Test::More tests => 6;
7 use lib 't/lib';
8 use SGN::Test::WWW::Mechanize;
10 use CXGN::Biosource::Schema;
12 my $base_url = $ENV{SGN_TEST_SERVER};
13 my $mech = SGN::Test::WWW::Mechanize->new;
15 ## First take variables for the test from the database ##
17 my @schema_list = ('biosource', 'metadata', 'public');
18 my $schema_list = join(',', @schema_list);
19 my $set_path = "SET search_path TO $schema_list";
21 my $dbh = $mech->context()->dbc()->dbh();
23 my $bs_schema = CXGN::Biosource::Schema->connect( sub { $dbh },
24 {on_connect_do => $set_path} );
27 ## WWW.SAMPLE TEST ###
29 my ($first_sample_row) = $bs_schema->resultset('BsSample')
30 ->search( undef,
32 order_by => {-asc => 'sample_id'},
33 rows => 1,
37 ## Now it will test the expected sample web-page if there is at least one row
38 ## in the database. If not, it will test the error page
40 if (defined $first_sample_row) {
42 my $first_sample_id = $first_sample_row->get_column('sample_id');
43 my $first_sample_name = $first_sample_row->get_column('sample_name');
45 $mech->get_ok("$base_url/biosource/sample.pl?id=$first_sample_id");
46 $mech->content_like(qr/Sample: $first_sample_name/);
47 $mech->content_unlike(qr/ERROR PAGE/);
49 $mech->get_ok("$base_url/biosource/sample.pl?name=$first_sample_name");
50 $mech->content_like(qr/Sample: $first_sample_name/);
51 $mech->content_unlike(qr/ERROR PAGE/);