@@ -, +, @@ --------- -- Or whatever yours is. With or without the trailing / -- before applying the other patch, there should be failures. -- there should be no failures now. --- t/db_dependent/www/catalogue_stats.t | 111 +++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 t/db_dependent/www/catalogue_stats.t --- a/t/db_dependent/www/catalogue_stats.t +++ a/t/db_dependent/www/catalogue_stats.t @@ -0,0 +1,111 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright (C) 2016 Mark Tompsett +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Test::More; +use Test::WWW::Mechanize; +use XML::Simple; + +my $koha_conf = $ENV{KOHA_CONF}; +my $xml = XMLin($koha_conf); + +my $user = $ENV{KOHA_USER} || $xml->{config}->{user}; +my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass}; +my $intranet = $ENV{KOHA_INTRANET_URL}; + +# test KOHA_INTRANET_URL is set +if ( not defined $intranet ) { + plan skip_all => + "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n"; +} + +$intranet =~ s/\/$//xsm; + +test_row_column_selection(); + +done_testing(); + +sub test_row_column_selection { + + my $agent = Test::WWW::Mechanize->new( autocheck => 1 ); + + $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", + 'connect to intranet' ); + $agent->form_name('loginform'); + $agent->field( 'password', $password ); + $agent->field( 'userid', $user ); + $agent->field( 'branch', q{} ); + $agent->click_ok( q{}, 'login to staff client' ); + + $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'load main page' ); + + $agent->follow_link_ok( { url_regex => qr/reports-home/xsmi }, + 'open reports module' ); + $agent->follow_link_ok( { url_regex => qr/catalogue_stats/xsmi }, + 'go to Catalog statistics' ); + + my $base_url = $agent->uri(); + note "Base URL: $base_url\n"; + my @test_urls = ( + '?Column=&Line=', + '?Column=test&Line=', + '?Column=items.itype&Line=', + '?Column=&Line=&do_it=1', + '?Column=test&Line=&do_it=1', + '?Column=items.itype&Line=&do_it=1', + '?Column=&Line=test', + '?Column=test&Line=test', + '?Column=items.itype&Line=test', + '?Column=&Line=test&do_it=1', + '?Column=test&Line=test&do_it=1', + '?Column=items.itype&Line=test&do_it=1', + '?Column=&Line=publishercode', + '?Column=test&Line=publishercode', + '?Column=items.itype&Line=publishercode', + '?Column=&Line=publishercode&do_it=1', + '?Column=test&Line=publishercode&do_it=1', + '?Column=items.itype&Line=publishercode&do_it=1', + '?Line=', + '?Line=&do_it=1', + '?Line=test', + '?Line=test&do_it=1', + '?Line=publishercode', + '?Line=publishercode&do_it=1', + '?Column=', + '?Column=&do_it=1', + '?Column=test', + '?Column=test&do_it=1', + '?Column=publishercode', + '?Column=publishercode&do_it=1', + q{?}, + '?do_it=1', + ); + + foreach my $test_url (@test_urls) { + my $current_url = $base_url . q{/} . $test_url; + eval { + $agent->get_ok( $current_url, 'Checking ' . $test_url ); + } || fail('Checking ' . $test_url . ' failed!'); + } + + return; +} + +1; --