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

(-)a/C4/Review.pm (-14 / +68 lines)
Lines 25-36 use C4::Context; Link Here
25
use vars qw($VERSION @ISA @EXPORT);
25
use vars qw($VERSION @ISA @EXPORT);
26
26
27
BEGIN {
27
BEGIN {
28
	# set the version for version checking
28
  # set the version for version checking
29
    $VERSION = 3.07.00.049;
29
    $VERSION = 3.07.00.049;
30
	require Exporter;
30
  require Exporter;
31
	@ISA    = qw(Exporter);
31
  @ISA    = qw(Exporter);
32
	@EXPORT = qw(getreview savereview updatereview numberofreviews numberofreviewsbybiblionumber
32
  @EXPORT = qw(getreview savereview updatereview numberofreviews numberofreviewsbybiblionumber
33
		getreviews getallreviews approvereview unapprovereview deletereview);
33
    getreviews getallreviews approvereview unapprovereview deletereview);
34
}
34
}
35
35
36
=head1 NAME
36
=head1 NAME
Lines 46-53 C4::Review - Perl Module containing routines for dealing with reviews of items Link Here
46
  updatereview($biblionumber,$borrowernumber,$review);
46
  updatereview($biblionumber,$borrowernumber,$review);
47
  my $count=numberofreviews($status);
47
  my $count=numberofreviews($status);
48
  my $count=numberofreviewsbybiblionumber($biblionumber);
48
  my $count=numberofreviewsbybiblionumber($biblionumber);
49
  my $reviews=getreviews($biblionumber);
49
  my $reviews=getreviews($biblionumber, $status);
50
  my $reviews=getallreviews($status);
50
  my $reviews=getallreviews($status, [$offset], [$row_count]);
51
51
52
=head1 DESCRIPTION
52
=head1 DESCRIPTION
53
53
Lines 73-88 sub getreview { Link Here
73
    return $sth->fetchrow_hashref();
73
    return $sth->fetchrow_hashref();
74
}
74
}
75
75
76
=head2 savereview
77
78
  savereview($biblionumber,$borrowernumber, $review);
79
80
Save a review in the 'reviews' database
81
82
=cut
83
76
sub savereview {
84
sub savereview {
77
    my ( $biblionumber, $borrowernumber, $review ) = @_;
85
    my ( $biblionumber, $borrowernumber, $review ) = @_;
78
    my $dbh   = C4::Context->dbh;
86
    my $dbh   = C4::Context->dbh;
79
    my $query = "INSERT INTO reviews (borrowernumber,biblionumber,
87
    my $query = "INSERT INTO reviews (borrowernumber,biblionumber,
80
	review,approved,datereviewed) VALUES 
88
  review,approved,datereviewed) VALUES
81
  (?,?,?,0,now())";
89
  (?,?,?,0,now())";
82
    my $sth = $dbh->prepare($query);
90
    my $sth = $dbh->prepare($query);
83
    $sth->execute( $borrowernumber, $biblionumber, $review);
91
    $sth->execute( $borrowernumber, $biblionumber, $review);
84
}
92
}
85
93
94
=head2 updatereview
95
96
  updateview($biblionumber,$borrowernumber, $review);
97
98
Update the review description in the 'reviews' database
99
100
=cut
101
86
sub updatereview {
102
sub updatereview {
87
    my ( $biblionumber, $borrowernumber, $review ) = @_;
103
    my ( $biblionumber, $borrowernumber, $review ) = @_;
88
    my $dbh   = C4::Context->dbh;
104
    my $dbh   = C4::Context->dbh;
Lines 91-96 sub updatereview { Link Here
91
    $sth->execute( $review, $borrowernumber, $biblionumber );
107
    $sth->execute( $review, $borrowernumber, $biblionumber );
92
}
108
}
93
109
110
=head2 numberofreviews
111
112
  my $count=numberofreviews( [$status] );
113
114
Return the number of reviews where in the 'reviews' database : 'approved' = $status
115
(By default $status = 1)
116
117
=cut
118
94
sub numberofreviews {
119
sub numberofreviews {
95
    my ($param) = @_;
120
    my ($param) = @_;
96
    my $status = (defined($param) ? $param : 1);
121
    my $status = (defined($param) ? $param : 1);
Lines 102-107 sub numberofreviews { Link Here
102
  return $sth->fetchrow;
127
  return $sth->fetchrow;
103
}
128
}
104
129
130
=head2 numberofreviewsbybiblionumber
131
132
  my $count=numberofreviewsbybiblionumber($biblionumber);
133
134
Return the number of reviews approved for a given biblionumber
135
136
=cut
137
105
sub numberofreviewsbybiblionumber {
138
sub numberofreviewsbybiblionumber {
106
    my ($biblionumber) = @_;
139
    my ($biblionumber) = @_;
107
    my $dbh            = C4::Context->dbh;
140
    my $dbh            = C4::Context->dbh;
Lines 109-136 sub numberofreviewsbybiblionumber { Link Here
109
      "SELECT count(*) FROM reviews WHERE biblionumber=? and approved=?";
142
      "SELECT count(*) FROM reviews WHERE biblionumber=? and approved=?";
110
    my $sth = $dbh->prepare($query);
143
    my $sth = $dbh->prepare($query);
111
    $sth->execute( $biblionumber, 1 );
144
    $sth->execute( $biblionumber, 1 );
112
	return $sth->fetchrow;
145
  return $sth->fetchrow;
113
}
146
}
114
147
148
=head2 getreviews
149
150
  my $reviews=getreviews($biblionumber, $status);
151
152
Return all reviews where in the 'reviews' database :
153
'biblionumber' = $biblionumber and 'approved' = $status
154
155
=cut
156
115
sub getreviews {
157
sub getreviews {
116
    my ( $biblionumber, $approved ) = @_;
158
    my ( $biblionumber, $approved ) = @_;
117
    my $dbh   = C4::Context->dbh;
159
    my $dbh   = C4::Context->dbh;
118
    my $query =
160
    my $query =
119
"SELECT * FROM reviews WHERE biblionumber=? and approved=? order by datereviewed desc";
161
      "SELECT * FROM reviews WHERE biblionumber=? and approved=? order by datereviewed desc";
120
    my $sth = $dbh->prepare($query) || warn $dbh->err_str;
162
    my $sth = $dbh->prepare($query);
121
    $sth->execute( $biblionumber, $approved );
163
    $sth->execute( $biblionumber, $approved );
122
	return $sth->fetchall_arrayref({});
164
  return $sth->fetchall_arrayref({});
123
}
165
}
124
166
167
=head2 getallreviews
168
169
  my $reviews=getallreviews($status, [$offset], [$row_count]);
170
171
Return all reviews where in the 'reviews' database : 'approved' = $status
172
173
If offset and row_count are fiven, it's return all reviews between the
174
$offset position and the ($offset + $row_count) position.
175
(By default : $offset = 0 and $row_count = 20)
176
177
=cut
178
125
sub getallreviews {
179
sub getallreviews {
126
    my ($status, $offset, $row_count) = @_;
180
    my ($status, $offset, $row_count) = @_;
127
    my @params = ($status,($offset ? $offset : 0),($row_count ? $row_count : 20));
181
    my @params = ($status,($offset ? $offset : 0),($row_count ? $row_count : 20));
128
    my $dbh      = C4::Context->dbh;
182
    my $dbh      = C4::Context->dbh;
129
    my $query    =
183
    my $query    =
130
      "SELECT * FROM reviews WHERE approved=? order by datereviewed desc LIMIT ?, ?";
184
      "SELECT * FROM reviews WHERE approved=? order by datereviewed desc LIMIT ?, ?";
131
    my $sth = $dbh->prepare($query) || warn $dbh->err_str;
185
    my $sth = $dbh->prepare($query);
132
    $sth->execute(@params);
186
    $sth->execute(@params);
133
	return $sth->fetchall_arrayref({});
187
  return $sth->fetchall_arrayref({});
134
}
188
}
135
189
136
=head2 approvereview
190
=head2 approvereview
(-)a/t/db_dependent/Review.t (-1 / +414 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2015 BibLibre
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, see <http://www.gnu.org/licenses>.
18
19
use Modern::Perl;
20
use Test::More tests => 117;
21
use Time::Piece;
22
23
BEGIN {
24
    use_ok ('C4::Biblio');
25
    use_ok ('C4::Review');
26
    use_ok ('Koha::Borrower');
27
    use_ok ('MARC::Record');
28
}
29
30
can_ok(
31
    'C4::Review', qw(
32
        getreview
33
        savereview
34
        updatereview
35
        numberofreviews
36
        numberofreviewsbybiblionumber
37
        getreviews
38
        getallreviews
39
        approvereview
40
        unapprovereview
41
        deletereview )
42
);
43
44
45
my $dbh = C4::Context->dbh;
46
$dbh->{AutoCommit} = 0;
47
$dbh->{RaiseError} = 1;
48
$dbh->do('DELETE FROM reviews');
49
$dbh->do('DELETE FROM borrowers');
50
51
# ---------- Some borrowers for testing -------------------
52
my $categorycode = Koha::Database->new()->schema()->resultset('Category')->first()->categorycode();
53
my $branchcode   = Koha::Database->new()->schema()->resultset('Branch')  ->first()->branchcode();
54
55
my $b1 = Koha::Borrower->new(
56
    {
57
        surname      => 'Borrower 1',
58
        branchcode   => $branchcode,
59
        categorycode => $categorycode
60
    }
61
);
62
$b1->store();
63
64
my $b2 = Koha::Borrower->new(
65
    {
66
        surname      => 'Borrower 2',
67
        branchcode   => $branchcode,
68
        categorycode => $categorycode
69
    }
70
);
71
$b2->store();
72
73
my $b3 = Koha::Borrower->new(
74
    {
75
        surname      => 'Borrower 3',
76
        branchcode   => $branchcode,
77
        categorycode => $categorycode
78
    }
79
);
80
$b3->store();
81
82
83
# ---------- Some biblios for testing -------------------
84
my ( $biblionumber1 ) = AddBiblio( MARC::Record->new, '' );
85
my ( $biblionumber2 ) = AddBiblio( MARC::Record->new, '' );
86
my ( $biblionumber3 ) = AddBiblio( MARC::Record->new, '' );
87
88
89
# ---------- Some reviews for testing -------------------
90
my $rev1 = 'Review 1';
91
my $rev2 = 'Review 2';
92
my $rev3 = 'Review 3';
93
94
95
# ---------- Testing savereview ---------------------------
96
my $date = Time::Piece::localtime->strftime('%F %T');
97
98
savereview($biblionumber1,$b1->borrowernumber,$rev1);
99
100
my $query = '
101
  SELECT count(*)
102
  FROM reviews
103
';
104
my $sth = $dbh->prepare($query);
105
$sth->execute;
106
my $count = $sth->fetchrow_array;
107
is ($count, 1, 'There is 1 review');
108
109
$query = '
110
  SELECT reviewid, borrowernumber, biblionumber, review, approved, datereviewed
111
  FROM reviews
112
';
113
$sth = $dbh->prepare($query);
114
$sth->execute;
115
my ($reviewid, $borrowernumber, $biblionumber, $review, $approved, $datereviewed) = $sth->fetchrow_array;
116
is ($borrowernumber, $b1->borrowernumber, 'borrowernumber field is good'  );
117
is ($biblionumber,   $biblionumber1,      'biblionumber field is good'    );
118
is ($review,         $rev1,               'review field is good'          );
119
is ($approved,       0,                   'approved field is 0 by default');
120
is ($datereviewed,   $date,               'datereviewed field is good'    );
121
122
# We add some others reviews
123
savereview($biblionumber1,$b2->borrowernumber,$rev2);
124
savereview($biblionumber3,$b2->borrowernumber,$rev3);
125
126
127
# ---------- Testing getreview ----------------------------
128
my $review1 = getreview($biblionumber1,$b1->borrowernumber);
129
my $review2 = getreview($biblionumber1,$b2->borrowernumber);
130
my $review3 = getreview($biblionumber3,$b2->borrowernumber);
131
132
$query = '
133
  SELECT count(*)
134
  FROM reviews
135
';
136
$sth = $dbh->prepare($query);
137
$sth->execute;
138
$count = $sth->fetchrow_array;
139
is ($count, 3, 'There are 3 reviews');
140
141
isa_ok ($review1, 'HASH', '$review1 is defined as a hash');
142
is ($review1->{borrowernumber}, $b1->borrowernumber, 'borrowernumber field is good'  );
143
is ($review1->{biblionumber},   $biblionumber1,      'biblionumber field is good'    );
144
is ($review1->{review},         $rev1,               'review field is good'          );
145
is ($review1->{approved},       0,                   'approved field is 0 by default');
146
cmp_ok ($review1->{datereviewed}, 'ge' ,$date , 'datereviewed field is good');
147
148
isa_ok ($review2, 'HASH', '$review2 is defined as a hash');
149
is ($review2->{borrowernumber}, $b2->borrowernumber, 'borrowernumber field is good'  );
150
is ($review2->{biblionumber},   $biblionumber1,      'biblionumber field is good'    );
151
is ($review2->{review},         $rev2,               'review field is good'          );
152
is ($review2->{approved},       0,                   'approved field is 0 by default');
153
cmp_ok ($review2->{datereviewed}, 'ge' ,$date , 'datereviewed field is good');
154
155
isa_ok ($review3, 'HASH', '$review3 is defined as a hash');
156
is ($review3->{borrowernumber}, $b2->borrowernumber, 'borrowernumber field is good'  );
157
is ($review3->{biblionumber},   $biblionumber3,      'biblionumber field is good'    );
158
is ($review3->{review},         $rev3,               'review field is good'          );
159
is ($review3->{approved},       0,                   'approved field is 0 by default');
160
cmp_ok ($review3->{datereviewed}, 'ge' ,$date , 'datereviewed field is good');
161
162
163
# ---------- Testing getreviews ---------------------------
164
my $status = 0;
165
my $reviews = getreviews($biblionumber1, $status);
166
167
$query = '
168
  SELECT count(*)
169
  FROM reviews
170
  WHERE biblionumber = ?
171
    AND approved = ?
172
';
173
$sth = $dbh->prepare($query);
174
$sth->execute($biblionumber1, $status);
175
$count = $sth->fetchrow_array;
176
is ($count, 2, 'There are 2 reviews corresponding');
177
178
isa_ok ($reviews, 'ARRAY', '$reviews is defined as an array');
179
180
isa_ok ($reviews->[0], 'HASH', '$reviews->[0] is defined as a hash');
181
is ($reviews->[0]->{reviewid},       $review1->{reviewid},       'reviewid field is good'        );
182
is ($reviews->[0]->{borrowernumber}, $review1->{borrowernumber}, 'borrowernumber field is good'  );
183
is ($reviews->[0]->{biblionumber},   $review1->{biblionumber},   'biblionumber field is good'    );
184
is ($reviews->[0]->{review},         $review1->{review},         'review field is good'          );
185
is ($reviews->[0]->{approved},       $review1->{approved},       'approved field is 0 by default');
186
cmp_ok ($reviews->[0]->{datereviewed}, 'ge', $date, 'datereviewed field is good');
187
188
isa_ok ($reviews->[1], 'HASH', '$reviews->[1] is defined as a hash');
189
is ($reviews->[1]->{reviewid},       $review2->{reviewid},       'reviewid field is good'        );
190
is ($reviews->[1]->{borrowernumber}, $review2->{borrowernumber}, 'borrowernumber field is good'  );
191
is ($reviews->[1]->{biblionumber},   $review2->{biblionumber},   'biblionumber field is good'    );
192
is ($reviews->[1]->{review},         $review2->{review},         'review field is good'          );
193
is ($reviews->[1]->{approved},       $review2->{approved},       'approved field is 0 by default');
194
cmp_ok ($reviews->[1]->{datereviewed}, 'ge', $date, 'datereviewed field is good');
195
196
$status = 1;
197
$reviews = getreviews($biblionumber1, $status);
198
isa_ok ($reviews, 'ARRAY', '$reviews is defined as an array');
199
is_deeply($reviews, [], '$reviews is empty, there is no approved review' );
200
201
202
# ---------- Testing getallreviews ------------------------
203
$status = 1;
204
$reviews = getallreviews($status);
205
isa_ok ($reviews, 'ARRAY', '$reviews is defined as an array');
206
is_deeply($reviews, [], '$reviews is empty, there is no approved review' );
207
208
209
$status = 0;
210
$reviews = getallreviews($status);
211
212
$query = '
213
  SELECT count(*)
214
  FROM reviews
215
  WHERE approved = ?
216
';
217
$sth = $dbh->prepare($query);
218
$sth->execute($status);
219
$count = $sth->fetchrow_array;
220
is ($count, 3, 'There are 3 reviews corresponding');
221
222
my $count2 = numberofreviews($status);
223
is ($count2, $count, 'number of reviews returned is good');
224
225
226
isa_ok ($reviews, 'ARRAY', '$reviews is defined as an array');
227
228
isa_ok ($reviews->[0], 'HASH', '$reviews->[0] is defined as a hash');
229
is ($reviews->[0]->{reviewid},       $review1->{reviewid},       'reviewid field is good'        );
230
is ($reviews->[0]->{borrowernumber}, $review1->{borrowernumber}, 'borrowernumber field is good'  );
231
is ($reviews->[0]->{biblionumber},   $review1->{biblionumber},   'biblionumber field is good'    );
232
is ($reviews->[0]->{review},         $review1->{review},         'review field is good'          );
233
is ($reviews->[0]->{approved},       $review1->{approved},       'approved field is 0 by default');
234
cmp_ok ($reviews->[0]->{datereviewed}, 'ge' ,$date , 'datereviewed field is good');
235
236
isa_ok ($reviews->[1], 'HASH', '$reviews->[1] is defined as a hash');
237
is ($reviews->[1]->{reviewid},       $review2->{reviewid},       'reviewid field is good'        );
238
is ($reviews->[1]->{borrowernumber}, $review2->{borrowernumber}, 'borrowernumber field is good'  );
239
is ($reviews->[1]->{biblionumber},   $review2->{biblionumber},   'biblionumber field is good'    );
240
is ($reviews->[1]->{review},         $review2->{review},         'review field is good'          );
241
is ($reviews->[1]->{approved},       $review2->{approved},       'approved field is 0 by default');
242
cmp_ok ($reviews->[1]->{datereviewed}, 'ge' ,$date , 'datereviewed field is good');
243
244
isa_ok ($reviews->[2], 'HASH', '$reviews->[2] is defined as a hash');
245
is ($reviews->[2]->{reviewid},       $review3->{reviewid},       'reviewid field is good'        );
246
is ($reviews->[2]->{borrowernumber}, $review3->{borrowernumber}, 'borrowernumber field is good'  );
247
is ($reviews->[2]->{biblionumber},   $review3->{biblionumber},   'biblionumber field is good'    );
248
is ($reviews->[2]->{review},         $review3->{review},         'review field is good'          );
249
is ($reviews->[2]->{approved},       $review3->{approved},       'approved field is 0 by default');
250
cmp_ok ($reviews->[2]->{datereviewed}, 'ge' ,$date , 'datereviewed field is good');
251
252
my $offset = 1;
253
my $row_count = 1;
254
$reviews = getallreviews($status, $offset);
255
is (@$reviews, 2, 'There are only 2 Reviews here');
256
is_deeply ($reviews->[0], $review2, 'We have Review2...');
257
is_deeply ($reviews->[1], $review3, '...and Review3');
258
259
$reviews = getallreviews($status, $offset, $row_count);
260
is (@$reviews, 1, 'There is only 1 Review here');
261
is_deeply ($reviews->[0], $review2, 'We have only Review2');
262
263
264
# ---------- Testing numberofreviews ----------------------
265
$status = 0;
266
$count = numberofreviews($status);
267
is($count, 3, 'There are 3 reviews where approved = 0');
268
269
$status = 1;
270
$count = numberofreviews($status);
271
is($count, 0, 'There is no review where approved = 0');
272
273
$count = numberofreviews();
274
is($count, 0, 'There is no review where approved = 0 (Default)');
275
276
277
# ---------- Testing approvereview ------------------------
278
is($review1->{approved}, 0, 'review1 is not approved');
279
approvereview($review1->{reviewid});
280
$review1 = getreview($biblionumber1,$b1->borrowernumber);
281
is($review1->{approved}, 1, 'review1 is approved');
282
283
is($review2->{approved}, 0, 'review2 is not approved');
284
approvereview($review2->{reviewid});
285
$review2 = getreview($biblionumber1,$b2->borrowernumber);
286
is($review2->{approved}, 1, 'review2 is approved');
287
288
is($review3->{approved}, 0, 'review3 is not approved');
289
approvereview($review3->{reviewid});
290
$review3 = getreview($biblionumber3,$b2->borrowernumber);
291
is($review3->{approved}, 1, 'review3 is approved');
292
293
$status = 1;
294
$reviews = getallreviews($status);
295
296
$count = numberofreviews($status);
297
is ($count, 3, '3 reviews are approved');
298
299
$status = 0;
300
$count = numberofreviews($status);
301
is ($count, 0, 'No review are not approved');
302
303
304
# ---------- Testing unapprovereview ----------------------
305
is($review1->{approved}, 1, 'review1 is approved');
306
unapprovereview($review1->{reviewid});
307
$review1 = getreview($biblionumber1,$b1->borrowernumber);
308
is($review1->{approved}, 0, 'review1 is not approved');
309
310
is($review2->{approved}, 1, 'review2 is approved');
311
unapprovereview($review2->{reviewid});
312
$review2 = getreview($biblionumber1,$b2->borrowernumber);
313
is($review2->{approved}, 0, 'review2 is not approved');
314
315
is($review3->{approved}, 1, 'review3 is approved');
316
unapprovereview($review3->{reviewid});
317
$review3 = getreview($biblionumber3,$b2->borrowernumber);
318
is($review3->{approved}, 0, 'review3 is not approved');
319
320
$status = 0;
321
$reviews = getallreviews($status);
322
323
$count = numberofreviews($status);
324
is ($count, 3, '3 reviews are not approved');
325
326
$status = 1;
327
$count = numberofreviews($status);
328
is ($count, 0, 'No review are approved');
329
330
331
# ---------- Testing numberofreviewsbybiblionumber --------
332
approvereview($review1->{reviewid});
333
approvereview($review2->{reviewid});
334
approvereview($review3->{reviewid});
335
336
$biblionumber = $biblionumber1;
337
$count = numberofreviewsbybiblionumber($biblionumber);
338
is($count, 2, 'There are 2 reviews for biblionumber1 and approved = 1');
339
340
$biblionumber = $biblionumber2;
341
$count = numberofreviewsbybiblionumber($biblionumber);
342
is($count, 0, 'There is no review for biblionumber2 and  approved = 1');
343
344
$biblionumber = $biblionumber3;
345
$count = numberofreviewsbybiblionumber($biblionumber);
346
is($count, 1, 'There 1 review for biblionumber3 and approved = 1');
347
348
unapprovereview($review1->{reviewid});
349
unapprovereview($review3->{reviewid});
350
351
$biblionumber = $biblionumber1;
352
$count = numberofreviewsbybiblionumber($biblionumber);
353
is($count, 1, 'There is 1 review for biblionumber1 and approved = 1');
354
355
$biblionumber = $biblionumber2;
356
$count = numberofreviewsbybiblionumber($biblionumber);
357
is($count, 0, 'There is no review for biblionumber2 and  approved = 1');
358
359
$biblionumber = $biblionumber3;
360
$count = numberofreviewsbybiblionumber($biblionumber);
361
is($count, 0, 'There is no review for biblionumber3 and approved = 1');
362
363
364
# ---------- Testing updatereview -------------------------
365
my $rev1b = 'Review 1 bis';
366
my $rev2b = 'Review 2 bis';
367
my $rev3b = 'Review 3 bis';
368
369
is ($review1->{review}, $rev1, 'review field is "Review 1"');
370
updatereview($biblionumber1,$b1->borrowernumber,$rev1b);
371
$review1 = getreview($biblionumber1, $b1->borrowernumber);
372
is ($review1->{review}, $rev1b, 'review field is "Review 1 bis"');
373
374
is ($review2->{review}, $rev2, 'review field is "Review 2"');
375
updatereview($biblionumber1,$b2->borrowernumber,$rev2b);
376
$review2 = getreview($biblionumber1, $b2->borrowernumber);
377
is ($review2->{review}, $rev2b, 'review field is "Review 2 bis"');
378
379
is ($review3->{review}, $rev3, 'review field is "Review 3"');
380
updatereview($biblionumber3,$b2->borrowernumber,$rev3b);
381
$review3 = getreview($biblionumber3, $b2->borrowernumber);
382
is ($review3->{review}, $rev3b, 'review field is "Review 3 bis"');
383
384
385
# ---------- Testing deletereview -------------------------
386
my $status0 = 0;
387
my $status1 = 1;
388
389
my $numberOfReviews = numberofreviews($status0) + numberofreviews($status1);
390
is ($numberOfReviews, 3, 'There are 3 reviews in database');
391
392
deletereview($review1->{reviewid});
393
$review1 = getreview($biblionumber1, $b3->borrowernumber);
394
ok (!defined($review1), 'Review1 is no longer defined');
395
396
$numberOfReviews = numberofreviews($status0) + numberofreviews($status1);
397
is ($numberOfReviews, 2, 'There are 2 reviews left in database');
398
399
deletereview($review2->{reviewid});
400
$review2 = getreview($biblionumber2, $b2->borrowernumber);
401
ok (!defined($review2), 'Review2 is no longer defined');
402
403
$numberOfReviews = numberofreviews($status0) + numberofreviews($status1);
404
is ($numberOfReviews, 1, 'There is 1 review left in database');
405
406
deletereview($review3->{reviewid});
407
$review3 = getreview($biblionumber3, $b2->borrowernumber);
408
ok (!defined($review3), 'Review3 is no longer defined');
409
410
$numberOfReviews = numberofreviews($status0) + numberofreviews($status1);
411
is ($numberOfReviews, 0, 'There is no review left in database');
412
413
414
$dbh->rollback;

Return to bug 13969