|
Lines 18-28
Link Here
|
| 18 |
|
18 |
|
| 19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
| 20 |
|
20 |
|
| 21 |
use Test::More tests => 117; |
21 |
use Test::More tests => 118; |
| 22 |
use t::lib::TestBuilder; |
22 |
use t::lib::TestBuilder; |
| 23 |
|
23 |
|
| 24 |
use Koha::Database; |
24 |
use Koha::Database; |
| 25 |
use Time::Piece; |
25 |
use Time::Piece; |
|
|
26 |
use Test::MockModule; |
| 26 |
|
27 |
|
| 27 |
BEGIN { |
28 |
BEGIN { |
| 28 |
use_ok('C4::Biblio'); |
29 |
use_ok('C4::Biblio'); |
|
Lines 58-63
my $builder = t::lib::TestBuilder->new;
Link Here
|
| 58 |
# ---------- Some borrowers for testing ------------------- |
59 |
# ---------- Some borrowers for testing ------------------- |
| 59 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
60 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
| 60 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
61 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
|
|
62 |
my $branchcode2 = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 63 |
|
| 64 |
my $context = new Test::MockModule('C4::Context'); |
| 65 |
$context->mock( |
| 66 |
'userenv', |
| 67 |
sub { |
| 68 |
return { |
| 69 |
flags => 0, |
| 70 |
id => 'my_userid', |
| 71 |
branch => $branchcode, |
| 72 |
}; |
| 73 |
} |
| 74 |
); |
| 61 |
|
75 |
|
| 62 |
my $b1 = Koha::Patron->new( |
76 |
my $b1 = Koha::Patron->new( |
| 63 |
{ surname => 'Borrower 1', |
77 |
{ surname => 'Borrower 1', |
|
Lines 246-251
$reviews = getallreviews( $status, $offset, $row_count );
Link Here
|
| 246 |
is( @$reviews, 1, 'There is only 1 Review here' ); |
260 |
is( @$reviews, 1, 'There is only 1 Review here' ); |
| 247 |
is_deeply( $reviews->[0], $review2, 'We have only Review2' ); |
261 |
is_deeply( $reviews->[0], $review2, 'We have only Review2' ); |
| 248 |
|
262 |
|
|
|
263 |
$context->mock( |
| 264 |
'userenv', |
| 265 |
sub { |
| 266 |
return { |
| 267 |
flags => 0, |
| 268 |
id => 'my_userid', |
| 269 |
branch => $branchcode2, |
| 270 |
}; |
| 271 |
} |
| 272 |
); |
| 273 |
my $no_reviews = getallreviews($status); |
| 274 |
is( @{$no_reviews}, 0, "No reviews returned for unused branchcode" ); |
| 275 |
$context->mock( |
| 276 |
'userenv', |
| 277 |
sub { |
| 278 |
return { |
| 279 |
flags => 0, |
| 280 |
id => 'my_userid', |
| 281 |
branch => $branchcode, |
| 282 |
}; |
| 283 |
} |
| 284 |
); |
| 285 |
|
| 286 |
|
| 249 |
# ---------- Testing numberofreviews ---------------------- |
287 |
# ---------- Testing numberofreviews ---------------------- |
| 250 |
$status = 0; |
288 |
$status = 0; |
| 251 |
$count = numberofreviews($status); |
289 |
$count = numberofreviews($status); |
| 252 |
- |
|
|