3 # Copyright 2012 C & P Bibliography Services
5 # This is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # This is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
22 use Test::WWW::Mechanize;
31 my $testdir = File::Spec->rel2abs( dirname(__FILE__) );
33 my $koha_conf = $ENV{KOHA_CONF};
34 my $xml = XMLin($koha_conf);
40 plan skip_all => "Tests skip. You must have a working Context\n";
44 my $user = $ENV{KOHA_USER} || $xml->{config}->{user};
45 my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass};
46 my $intranet = $ENV{KOHA_INTRANET_URL};
48 my $mysql_on = ProgProcesses('mysql');
52 plan skip_all => "Tests skip. You must start Mysql to do those tests\n";
55 if (not defined $intranet) {
56 plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n";
62 my $agent = Test::WWW::Mechanize->new( autocheck => 1 );
65 # -------------------------------------------------- LOAD RECORD
67 $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'connect to intranet' );
68 $agent->form_name('loginform');
69 $agent->field( 'password', $password );
70 $agent->field( 'userid', $user );
71 $agent->field( 'branch', '' );
72 $agent->click_ok( '', 'login to staff client' );
73 $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'load main page' );
75 $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Connect to Authorized values page' );
76 $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=add_form", 'Open to create a new category' );
77 $agent->form_name('Aform');
78 $agent->field('authorised_value', 'επιμεq');
79 $agent->field('lib_opac', 'autdesc2');
80 $agent->field('lib', 'desc1');
81 $agent->field('category', '学協会μμ');
82 $agent->field('branches', '');
83 $agent->click_ok( '', "Create new auth category and value" );
85 $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Return to Authorized values page' );
86 $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?searchfield=学協会μμ&offset=0", 'Search the values inserted' );
87 my $text = $agent->text() ;
89 ok ( ( length(Encode::encode_utf8($text)) != length($text) ) , 'UTF-8 are multi-byte. Good') ;
90 ok ($text =~ m/学協会μμ/, 'UTF-8 (Asia) chars are correctly present. Good');
91 ok ($text =~ m/επιμεq/, 'UTF-8 (Greek) chars are correctly present. Good');
92 my @links = $agent->links;
94 foreach my $dato (@links){
95 my $link = $dato->url;
96 if ($link =~ m/op=delete_confirm\&searchfield=学協会μμ/){
97 $link =~ m/(.*&id=?)(\d{1,})(&.*)/;
103 $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=delete_confirmed&searchfield=学協会μμ&id=$id_to_del", 'UTF_8 auth. value deleted' );
105 ok($id_to_del ne undef, "error, link to delete nor working");
111 return scalar grep /$_[0]/, (split /\n/, `ps -aef`);