|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 90; |
20 |
use Test::More tests => 91; |
| 21 |
|
21 |
|
| 22 |
BEGIN { |
22 |
BEGIN { |
| 23 |
require_ok('C4::Circulation'); |
23 |
require_ok('C4::Circulation'); |
|
Lines 36-41
use C4::Reserves;
Link Here
|
| 36 |
use C4::Overdues qw(UpdateFine CalcFine); |
36 |
use C4::Overdues qw(UpdateFine CalcFine); |
| 37 |
use Koha::DateUtils; |
37 |
use Koha::DateUtils; |
| 38 |
use Koha::Database; |
38 |
use Koha::Database; |
|
|
39 |
use Koha::Subscriptions; |
| 39 |
|
40 |
|
| 40 |
my $schema = Koha::Database->schema; |
41 |
my $schema = Koha::Database->schema; |
| 41 |
$schema->storage->txn_begin; |
42 |
$schema->storage->txn_begin; |
|
Lines 1248-1253
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
| 1248 |
is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31' ); |
1249 |
is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31' ); |
| 1249 |
}; |
1250 |
}; |
| 1250 |
|
1251 |
|
|
|
1252 |
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { |
| 1253 |
plan tests => 5; |
| 1254 |
|
| 1255 |
my $library = $builder->build( { source => 'Branch' } ); |
| 1256 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 1257 |
|
| 1258 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
| 1259 |
my $biblionumber = $biblioitem->{biblionumber}; |
| 1260 |
my $item_1 = $builder->build( |
| 1261 |
{ source => 'Item', |
| 1262 |
value => { |
| 1263 |
homebranch => $library->{branchcode}, |
| 1264 |
holdingbranch => $library->{branchcode}, |
| 1265 |
notforloan => 0, |
| 1266 |
itemlost => 0, |
| 1267 |
withdrawn => 0, |
| 1268 |
biblionumber => $biblionumber, |
| 1269 |
} |
| 1270 |
} |
| 1271 |
); |
| 1272 |
my $item_2 = $builder->build( |
| 1273 |
{ source => 'Item', |
| 1274 |
value => { |
| 1275 |
homebranch => $library->{branchcode}, |
| 1276 |
holdingbranch => $library->{branchcode}, |
| 1277 |
notforloan => 0, |
| 1278 |
itemlost => 0, |
| 1279 |
withdrawn => 0, |
| 1280 |
biblionumber => $biblionumber, |
| 1281 |
} |
| 1282 |
} |
| 1283 |
); |
| 1284 |
|
| 1285 |
my ( $error, $question, $alerts ); |
| 1286 |
my $issue = AddIssue( $patron, $item_1->{barcode}, dt_from_string->add( days => 1 ) ); |
| 1287 |
|
| 1288 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
| 1289 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1290 |
is( keys(%$error) + keys(%$alerts), 0, 'No error or alert should be raised' ); |
| 1291 |
is( $question->{BIBLIO_ALREADY_ISSUED}, 1, 'BIBLIO_ALREADY_ISSUED question flag should be set if AllowMultipleIssuesOnABiblio=0 and issue already exists' ); |
| 1292 |
|
| 1293 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); |
| 1294 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1295 |
is( keys(%$error) + keys(%$question) + keys(%$alerts), 0, 'No BIBLIO_ALREADY_ISSUED flag should be set if AllowMultipleIssuesOnABiblio=1' ); |
| 1296 |
|
| 1297 |
# Add a subscription |
| 1298 |
Koha::Subscription->new({ biblionumber => $biblionumber })->store; |
| 1299 |
|
| 1300 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
| 1301 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1302 |
is( keys(%$error) + keys(%$question) + keys(%$alerts), 0, 'No BIBLIO_ALREADY_ISSUED flag should be set if it iss a subscription' ); |
| 1303 |
|
| 1304 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); |
| 1305 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1306 |
is( keys(%$error) + keys(%$question) + keys(%$alerts), 0, 'No BIBLIO_ALREADY_ISSUED flag should be set if it iss a subscription' ); |
| 1307 |
}; |
| 1308 |
|
| 1251 |
sub set_userenv { |
1309 |
sub set_userenv { |
| 1252 |
my ( $library ) = @_; |
1310 |
my ( $library ) = @_; |
| 1253 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); |
1311 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); |
| 1254 |
- |
|
|