Bug 18773: Fix failing history.t test
[koha.git] / t / db_dependent / www / history.t
blobb71f7b66b5f08e066d6754f77e8201cf2e2a15e7
1 #!/usr/bin/perl
3 # This file is part of Koha.
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.
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.
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>.
18 use Modern::Perl;
20 use utf8;
21 use XML::Simple;
22 use Encode;
24 use Test::More tests => 4;
25 use Test::WWW::Mechanize;
27 my $koha_conf = $ENV{KOHA_CONF};
28 my $xml = XMLin($koha_conf);
30 eval{
31 use C4::Context;
33 if ($@) {
34 plan skip_all => "Tests skip. You must have a working Context\n";
37 my $user = $ENV{KOHA_USER} || $xml->{config}->{user};
38 my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass};
39 my $intranet = $ENV{KOHA_INTRANET_URL};
41 if (not defined $intranet) {
42 plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n";
46 $intranet =~ s#/$##;
48 my $agent = Test::WWW::Mechanize->new( autocheck => 1 );
50 # Login
51 $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'Load the intranet login page' );
52 $agent->form_name('loginform');
53 $agent->field( 'password', $password );
54 $agent->field( 'userid', $user );
55 $agent->field( 'branch', '' );
56 $agent->click( '', 'Login to the intranet' );
57 $agent->get_ok( "$intranet/cgi-bin/koha/about.pl", 'Load the about page' );
59 # Test about > timeline is correctly encoded
60 my $encoded_latin_name = Encode::encode('UTF-8', 'Frédéric Demians');
61 my $encoded_cyrillic_name = Encode::encode('UTF-8', 'Сергій Дубик');
62 my $history_page = Encode::encode('UTF-8', $agent->text());
64 like( $history_page, qr/$encoded_latin_name/, "Latin characters with umlauts show correctly on the history page." );
65 like( $history_page, qr/$encoded_cyrillic_name/, "Cyrillic characters with umlauts show correctly on the history page." );