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

(-)a/t/db_dependent/www/data/marc21utf8record.mrc (+1 lines)
Line 0 Link Here
1
00893cam  2200205 a 4500001000800000005001700008008004100025020001500066035001200081040001300093049000700106050002200113245027800135260004500413300003400458650002500492650002000517650001400537952013600551100880920140204215200.0140204m2005    gr a          001 0 gre d  a9603962481  a1008809  aAUHcAUH  bb714aSB405.9bK57 200502aO deuteros κηπουρός στο σπίτι σας :b1000 + 1 ερωτήσεις, 2000 + 2 απαντήσεις /c[μετάφραση Μουζακίτης, Βασίλης ; επιμέλεια - διόρθωση Βαρκαρόλη Μαριάννα.  aΑθήνα :bΚΑΛΟΚΑΘΗ,c2005.  a144 σ. :bεικ. ;c29 εκ 4aΚηπουρική 4a学協会. μμ 0aGardening  8main91380123ab7bb7g0l2m0oSB405.9.K57 2005p0070031504tc. 1xΜϞΖΗϚ ΜΖΗΜΚΜΙΖΑyd15zΔ10 - ΒζβθζμϝϠηϛ
(-)a/t/db_dependent/www/data/unimarcutf8record.mrc (+1 lines)
Line 0 Link Here
1
00862nam0a22002173i 4500001000200000005001700002090000600019100004100025101000800066200018700074210004300261215002400304600002000328601002000348702004700368702005200415710005500467801002300522942000700545995009200552220141116143328.0  a2  a20130409d2005    ||||0itay50      ba  aita1 aO deuteros pagosmios polemos kai to Olokautōma tōn Elliēoō Evraiōn, 1941 - 1944eEchirithio meletisfErena kai singrafi kimenōn: Alexios MenexiadisgPanayota Andrianopoulou  aAthinacEvraico Mouseio Ellathosd2005  a73 p.cill.d27 cm.  2学協会. μμ  2学協会. μμ 1aMenexiadisb, Alexios3IT\ICCU\LO1V\404551 1aAndrianopouloub, Panayota3IT\ICCU\LO1V\40455202aEvraico Mouseio Ellathos3IT\ICCU\LO1V\4045534070 3aITbICCUc20141104  cBK  0020304112233_00000000000000052014-11-1692btestctestf2014-0002k112233l2o0rBK
(-)a/t/db_dependent/www/opac_utf8.t (-1 / +217 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2012 C & P Bibliography Services
4
#
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
8
# version.
9
#
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.
13
#
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
17
#
18
19
use Modern::Perl;
20
use utf8;
21
use Test::More;
22
use Test::WWW::Mechanize;
23
use Data::Dumper;
24
use XML::Simple;
25
use JSON;
26
use File::Basename;
27
use File::Spec;
28
use POSIX;
29
use Encode;
30
31
my $testdir = File::Spec->rel2abs( dirname(__FILE__) );
32
33
my $koha_conf = $ENV{KOHA_CONF};
34
my $xml       = XMLin($koha_conf);
35
36
use C4::Context;
37
my $marcflavour = C4::Context->preference('marcflavour') || 'MARC21';
38
39
# For the purpose of this test, we can reasonably take MARC21 and NORMARC to be the same
40
my $file =
41
  $marcflavour eq 'UNIMARC'
42
  ? "$testdir/data/unimarcutf8record.mrc"
43
  : "$testdir/data/marc21utf8record.mrc";
44
45
my $user     = $ENV{KOHA_USER} || $xml->{config}->{user};
46
my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass};
47
my $intranet = $ENV{KOHA_INTRANET_URL};
48
my $opac     = $ENV{KOHA_OPAC_URL};
49
50
my $zebra_on = ProgProcesses('zebrasrv');
51
my $indexer_on = ProgProcesses('koha-index');
52
53
if ($zebra_on < 2) {
54
    plan skip_all => "Tests skip. You must start Zebra Server to do those tests\n";
55
}
56
57
if ($indexer_on < 2) {
58
    plan skip_all => "Tests skip. You must start Zebra Background indexer to do those tests\n";
59
}
60
61
if (not defined $intranet) {
62
   plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n";
63
}
64
if (not defined $opac) {
65
   plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n";
66
}
67
68
$intranet =~ s#/$##;
69
$opac     =~ s#/$##;
70
71
my $agent = Test::WWW::Mechanize->new( autocheck => 1 );
72
my $jsonresponse;
73
74
# -------------------------------------------------- LOAD RECORD
75
76
$agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'connect to intranet' );
77
$agent->form_name('loginform');
78
$agent->field( 'password', $password );
79
$agent->field( 'userid',   $user );
80
$agent->field( 'branch',   '' );
81
$agent->click_ok( '', 'login to staff client' );
82
83
$agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'load main page' );
84
85
$agent->follow_link_ok( { url_regex => qr/tools-home/i }, 'open tools module' );
86
$agent->follow_link_ok( { text => 'Stage MARC records for import' },
87
    'go to stage MARC' );
88
89
$agent->post(
90
    "$intranet/cgi-bin/koha/tools/upload-file.pl",
91
    [ 'fileToUpload' => [$file], ],
92
    'Content_Type' => 'form-data',
93
);
94
ok( $agent->success, 'uploaded file' );
95
96
$jsonresponse = decode_json $agent->content();
97
is( $jsonresponse->{'status'}, 'done', 'upload succeeded' );
98
my $fileid = $jsonresponse->{'fileid'};
99
100
$agent->get_ok( "$intranet/cgi-bin/koha/tools/stage-marc-import.pl",
101
    'reopen stage MARC page' );
102
$agent->submit_form_ok(
103
    {
104
        form_number => 5,
105
        fields      => {
106
            'uploadedfileid'  => $fileid,
107
            'nomatch_action'  => 'create_new',
108
            'overlay_action'  => 'replace',
109
            'item_action'     => 'always_add',
110
            'matcher'         => '',
111
            'comments'        => '',
112
            'encoding'        => 'utf8',
113
            'parse_items'     => '1',
114
            'runinbackground' => '1',
115
        }
116
    },
117
    'stage MARC'
118
);
119
120
$jsonresponse = decode_json $agent->content();
121
my $jobID = $jsonresponse->{'jobID'};
122
ok( $jobID, 'have job ID' );
123
124
my $completed = 0;
125
126
# if we haven't completed the batch in two minutes, it's not happening
127
for my $counter ( 1 .. 24 ) {
128
    $agent->get(
129
        "$intranet/cgi-bin/koha/tools/background-job-progress.pl?jobID=$jobID",
130
        "get job progress"
131
    );
132
    $jsonresponse = decode_json $agent->content();
133
    if ( $jsonresponse->{'job_status'} eq 'completed' ) {
134
        $completed = 1;
135
        last;
136
    }
137
    warn(
138
        (
139
            $jsonresponse->{'job_size'}
140
            ? floor(
141
                100 * $jsonresponse->{'progress'} / $jsonresponse->{'job_size'}
142
              )
143
            : '100'
144
        )
145
        . "% completed"
146
    );
147
    sleep 5;
148
}
149
is( $jsonresponse->{'job_status'}, 'completed', 'job was completed' );
150
151
$agent->get_ok(
152
    "$intranet/cgi-bin/koha/tools/stage-marc-import.pl",
153
    'reopen stage MARC page at end of upload'
154
);
155
$agent->submit_form_ok(
156
    {
157
        form_number => 5,
158
        fields      => {
159
            'uploadedfileid'  => $fileid,
160
            'nomatch_action'  => 'create_new',
161
            'overlay_action'  => 'replace',
162
            'item_action'     => 'always_add',
163
            'matcher'         => '1',
164
            'comments'        => '',
165
            'encoding'        => 'utf8',
166
            'parse_items'     => '1',
167
            'runinbackground' => '1',
168
            'completedJobID'  => $jobID,
169
        }
170
    },
171
    'stage MARC'
172
);
173
174
$agent->follow_link_ok( { text => 'Manage staged records' }, 'view batch' );
175
176
177
$agent->form_number(5);
178
$agent->field( 'framework', '' );
179
$agent->click_ok( 'mainformsubmit', "imported records into catalog" );
180
my $webpage = $agent->{content};
181
182
$webpage =~ /(.*<title>.*?)(\d{1,})(.*<\/title>)/sx;
183
my $id_batch = $2;
184
185
#Wait the indexer
186
sleep 35;
187
188
# -------------------------------------------------- TEST ON OPAC
189
190
191
$agent->get_ok( "$opac" , "got opac");
192
$agent->form_name('searchform');
193
$agent->field( 'q',   'deuteros' );
194
$agent->field( 'idx',   '' );
195
$agent->click( );
196
197
# ok( $agent->success, 'uploaded file' );
198
199
my $text = $agent->text() ;
200
201
#warn "1." . length(Encode::encode_utf8($text)) ;
202
#warn "2." . length($text) ;
203
204
ok ( ( length(Encode::encode_utf8($text)) != length($text) ) , 'has UTF-8 characters. Good.') ;
205
206
207
#-------------------------------------------------- REVERT
208
209
$agent->get_ok( "$intranet/cgi-bin/koha/tools/manage-marc-import.pl", 'view batch' );
210
$agent->form_name('clean_batch_'.$id_batch);
211
$agent->click();
212
213
done_testing();
214
215
sub ProgProcesses {
216
   return scalar grep /$_[0]/, (split /\n/, `ps -aef`);
217
}

Return to bug 13264