Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
5 |
# Copyright (C) 2016 Mark Tompsett |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it |
8 |
# under the terms of the GNU General Public License as published by |
9 |
# the Free Software Foundation; either version 3 of the License, or |
10 |
# (at your option) any later version. |
11 |
# |
12 |
# Koha is distributed in the hope that it will be useful, but |
13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
# GNU General Public License for more details. |
16 |
# |
17 |
# You should have received a copy of the GNU General Public License |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
20 |
use Modern::Perl; |
21 |
|
22 |
use Test::More; |
23 |
use Test::WWW::Mechanize; |
24 |
use XML::Simple; |
25 |
|
26 |
my $koha_conf = $ENV{KOHA_CONF}; |
27 |
my $xml = XMLin($koha_conf); |
28 |
|
29 |
my $user = $ENV{KOHA_USER} || $xml->{config}->{user}; |
30 |
my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass}; |
31 |
my $intranet = $ENV{KOHA_INTRANET_URL}; |
32 |
|
33 |
# test KOHA_INTRANET_URL is set |
34 |
if ( not defined $intranet ) { |
35 |
plan skip_all => |
36 |
"Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n"; |
37 |
} |
38 |
|
39 |
$intranet =~ s/\/$//xsm; |
40 |
|
41 |
test_row_column_selection(); |
42 |
|
43 |
done_testing(); |
44 |
|
45 |
sub test_row_column_selection { |
46 |
|
47 |
my $agent = Test::WWW::Mechanize->new( autocheck => 1 ); |
48 |
|
49 |
$agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", |
50 |
'connect to intranet' ); |
51 |
$agent->form_name('loginform'); |
52 |
$agent->field( 'password', $password ); |
53 |
$agent->field( 'userid', $user ); |
54 |
$agent->field( 'branch', q{} ); |
55 |
$agent->click_ok( q{}, 'login to staff client' ); |
56 |
|
57 |
$agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'load main page' ); |
58 |
|
59 |
$agent->follow_link_ok( { url_regex => qr/reports-home/xsmi }, |
60 |
'open reports module' ); |
61 |
$agent->follow_link_ok( { url_regex => qr/catalogue_stats/xsmi }, |
62 |
'go to Catalog statistics' ); |
63 |
|
64 |
my $base_url = $agent->uri(); |
65 |
note "Base URL: $base_url\n"; |
66 |
my @test_urls = ( |
67 |
'?Column=&Line=', |
68 |
'?Column=test&Line=', |
69 |
'?Column=items.itype&Line=', |
70 |
'?Column=&Line=&do_it=1', |
71 |
'?Column=test&Line=&do_it=1', |
72 |
'?Column=items.itype&Line=&do_it=1', |
73 |
'?Column=&Line=test', |
74 |
'?Column=test&Line=test', |
75 |
'?Column=items.itype&Line=test', |
76 |
'?Column=&Line=test&do_it=1', |
77 |
'?Column=test&Line=test&do_it=1', |
78 |
'?Column=items.itype&Line=test&do_it=1', |
79 |
'?Column=&Line=publishercode', |
80 |
'?Column=test&Line=publishercode', |
81 |
'?Column=items.itype&Line=publishercode', |
82 |
'?Column=&Line=publishercode&do_it=1', |
83 |
'?Column=test&Line=publishercode&do_it=1', |
84 |
'?Column=items.itype&Line=publishercode&do_it=1', |
85 |
'?Line=', |
86 |
'?Line=&do_it=1', |
87 |
'?Line=test', |
88 |
'?Line=test&do_it=1', |
89 |
'?Line=publishercode', |
90 |
'?Line=publishercode&do_it=1', |
91 |
'?Column=', |
92 |
'?Column=&do_it=1', |
93 |
'?Column=test', |
94 |
'?Column=test&do_it=1', |
95 |
'?Column=publishercode', |
96 |
'?Column=publishercode&do_it=1', |
97 |
q{?}, |
98 |
'?do_it=1', |
99 |
); |
100 |
|
101 |
foreach my $test_url (@test_urls) { |
102 |
my $current_url = $base_url . q{/} . $test_url; |
103 |
$agent->get_ok( $current_url, 'Checking ' . $test_url ); |
104 |
} |
105 |
|
106 |
return; |
107 |
} |
108 |
|
109 |
1; |