Bug 22600: Set 'commandline' interface appropriately
[koha.git] / t / db_dependent / www / history.t
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18 use Modern::Perl;
19
20 use utf8;
21 use XML::Simple;
22 use Encode;
23
24 use Test::More; #See plan tests => \d+ below
25 use Test::WWW::Mechanize;
26
27 my $koha_conf = $ENV{KOHA_CONF};
28 my $xml       = XMLin($koha_conf);
29
30 my $user     = $ENV{KOHA_USER} || $xml->{config}->{user};
31 my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass};
32 my $intranet = $ENV{KOHA_INTRANET_URL};
33
34
35 eval{
36     use C4::Context;
37 };
38 if ($@) {
39     plan skip_all => "Tests skip. You must have a working Context\n";
40 }
41 elsif (not defined $intranet) {
42     plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n";
43 }
44 else {
45     plan tests => 4;
46 }
47
48
49 $intranet =~ s#/$##;
50
51 my $agent = Test::WWW::Mechanize->new( autocheck => 1 );
52
53 # Login
54 $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'Load the intranet login page' );
55 $agent->form_name('loginform');
56 $agent->field( 'password', $password );
57 $agent->field( 'userid',   $user );
58 $agent->field( 'branch',   '' );
59 $agent->click( '', 'Login to the intranet' );
60 $agent->get_ok( "$intranet/cgi-bin/koha/about.pl", 'Load the about page' );
61
62 # Test about > timeline is correctly encoded
63 my $encoded_latin_name    = Encode::encode('UTF-8', 'Frédéric Demians');
64 my $encoded_cyrillic_name = Encode::encode('UTF-8', 'Сергій Дубик');
65 my $history_page          = Encode::encode('UTF-8', $agent->text());
66
67 like( $history_page, qr/$encoded_latin_name/, "Latin characters with umlauts show correctly on the history page." );
68 like( $history_page, qr/$encoded_cyrillic_name/, "Cyrillic characters with umlauts show correctly on the history page." );
69