View | Details | Raw Unified | Return to bug 13264
Collapse All | Expand All

(-)a/t/db_dependent/www/auth_values_input_www.t (-7 / +64 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use utf8;
20
use utf8;
21
use Test::More tests => 15;
21
use Test::More tests => 28;
22
use Test::WWW::Mechanize;
22
use Test::WWW::Mechanize;
23
use XML::Simple;
23
use XML::Simple;
24
use JSON;
24
use JSON;
Lines 53-62 $intranet =~ s#/$##; Link Here
53
53
54
my $agent = Test::WWW::Mechanize->new( autocheck => 1 );
54
my $agent = Test::WWW::Mechanize->new( autocheck => 1 );
55
my $jsonresponse;
55
my $jsonresponse;
56
my ($category, $expected_base, $add_form_link_exists, $delete_form_link_exists);
57
58
# -------------------------------------------------- LOGIN
56
59
57
# -------------------------------------------------- LOAD RECORD
58
60
59
my $category = '学協会μμ';
60
$agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'connect to intranet' );
61
$agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'connect to intranet' );
61
$agent->form_name('loginform');
62
$agent->form_name('loginform');
62
$agent->field( 'password', $password );
63
$agent->field( 'password', $password );
Lines 65-70 $agent->field( 'branch', '' ); Link Here
65
$agent->click_ok( '', 'login to staff client' );
66
$agent->click_ok( '', 'login to staff client' );
66
$agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'load main page' );
67
$agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'load main page' );
67
68
69
#--------------------------------------------------- Test with corean and greek chars
70
71
$category = '学協会μμ';
72
68
$agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Connect to Authorized values page' );
73
$agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Connect to Authorized values page' );
69
$agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=add_form", 'Open to create a new category' );
74
$agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=add_form", 'Open to create a new category' );
70
$agent->form_name('Aform');
75
$agent->form_name('Aform');
Lines 75-84 $agent->field('category', $category); Link Here
75
$agent->field('branches', '');
80
$agent->field('branches', '');
76
$agent->click_ok( '', "Create new auth category and value" );
81
$agent->click_ok( '', "Create new auth category and value" );
77
82
78
my $expected_base = q|authorised_values.pl\?searchfield=| . uri_escape_utf8( $category );
83
$expected_base = q|authorised_values.pl\?searchfield=| . uri_escape_utf8( $category );
79
$agent->base_like(qr|$expected_base|, "check base");
84
$agent->base_like(qr|$expected_base|, "check base");
80
my $add_form_link_exists = 0;
85
$add_form_link_exists = 0;
81
my $delete_form_link_exists = 0;
86
$delete_form_link_exists = 0;
82
for my $link ( $agent->links() ) {
87
for my $link ( $agent->links() ) {
83
    if ( $link->url =~ m|authorised_values.pl\?op=add_form&category=$category| ) {
88
    if ( $link->url =~ m|authorised_values.pl\?op=add_form&category=$category| ) {
84
        $add_form_link_exists = 1;
89
        $add_form_link_exists = 1;
Lines 112-115 if ($id_to_del) { Link Here
112
    ok($id_to_del ne undef, "error, link to delete nor working");
117
    ok($id_to_del ne undef, "error, link to delete nor working");
113
}
118
}
114
119
120
#---------------------------------------- Test with only latin utf-8 (could be taken as Latin-1/ISO 8859-1)
121
122
$category = 'tòmas';
123
124
$agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Connect to Authorized values page' );
125
$agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=add_form", 'Open to create a new category' );
126
$agent->form_name('Aform');
127
$agent->field('authorised_value', 'ràmen');
128
$agent->field('lib_opac', 'autdesc2');
129
$agent->field('lib', 'desc1');
130
$agent->field('category', $category);
131
$agent->field('branches', '');
132
$agent->click_ok( '', "Create new auth category and value" );
133
$agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?searchfield=tòmas&offset=0", 'Search the values inserted' );
134
135
$expected_base = q|authorised_values.pl\?searchfield=| . uri_escape_utf8( $category );
136
#$expected_base = q|authorised_values.pl\?searchfield=| . $category;
137
$agent->base_like(qr|$expected_base|, "check base");
138
$add_form_link_exists = 0;
139
$delete_form_link_exists = 0;
140
for my $link ( $agent->links() ) {
141
    if ( $link->url =~ m|authorised_values.pl\?op=add_form&category=$category| ) {
142
        $add_form_link_exists = 1;
143
    }elsif( $link->url =~ m|authorised_values.pl\?op=delete_confirm&searchfield=$category| ) {
144
        $delete_form_link_exists = 1;
145
    }
146
}
147
is( $add_form_link_exists, 1, );
148
is( $delete_form_link_exists, 1, );
149
150
$agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl", 'Return to Authorized values page' );
151
$agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?searchfield=tòmas&offset=0", 'Search the values inserted' );
152
my $text2 = $agent->text() ;
153
#Tests on UTF-8
154
ok ( ( length(Encode::encode('UTF-8', $text)) != length($text) ) , 'UTF-8 are multi-byte. Good') ;
155
ok ($text2 =~  m/tòmas/, 'UTF-8 not Latin-1 first test is OK. Good');
156
ok ($text2=~  m/ràmen/, 'UTF-8 not Latin-1 second test is OK. Good');
157
my @links2 = $agent->links;
158
my $id_to_del2 ='';
159
foreach my $dato (@links2){
160
    my $link = $dato->url;
161
    if ($link =~  m/op=delete_confirm\&searchfield=tòmas/){
162
        $link =~  m/(.*&id=?)(\d{1,})(&.*)/;
163
        $id_to_del2 = $2;
164
        last;
165
    };
166
}
167
if ($id_to_del2) {
168
    $agent->get_ok( "$intranet/cgi-bin/koha/admin/authorised_values.pl?op=delete_confirmed&searchfield=tòmas&id=$id_to_del2", 'UTF_8 auth. value deleted' );
169
}else{
170
    ok($id_to_del ne undef, "error, link to delete nor working");
171
}
172
115
1;
173
1;
116
- 

Return to bug 13264