Browse Source

Bug 30291: Changes to tests

t/db_dependent/Circulation.t
t/db_dependent/Circulation/CalcFine.t
t/db_dependent/Circulation/transferbook.t
t/db_dependent/Holds.t
t/db_dependent/Koha/Biblio.t
t/db_dependent/Koha/Item.t
t/db_dependent/Koha/Patron.t
t/db_dependent/Koha/Recall.t
t/db_dependent/Koha/Recalls.t
t/db_dependent/XSLT.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
rmain2205
Aleisha Amohia 8 months ago
committed by Fridolin Somers
parent
commit
d352c8e619
  1. 152
      t/db_dependent/Circulation.t
  2. 14
      t/db_dependent/Circulation/CalcFine.t
  3. 22
      t/db_dependent/Circulation/transferbook.t
  4. 12
      t/db_dependent/Holds.t
  5. 42
      t/db_dependent/Koha/Biblio.t
  6. 78
      t/db_dependent/Koha/Item.t
  7. 54
      t/db_dependent/Koha/Patron.t
  8. 70
      t/db_dependent/Koha/Recall.t
  9. 24
      t/db_dependent/Koha/Recalls.t
  10. 6
      t/db_dependent/XSLT.t

152
t/db_dependent/Circulation.t

@ -1458,11 +1458,11 @@ subtest "CanBookBeRenewed tests" => sub {
# item-level and this item: renewal not allowed
my $recall = Koha::Recall->new({
biblionumber => $recall_item1->biblionumber,
itemnumber => $recall_item1->itemnumber,
borrowernumber => $recall_borrower->borrowernumber,
branchcode => $recall_borrower->branchcode,
item_level_recall => 1,
biblio_id => $recall_item1->biblionumber,
item_id => $recall_item1->itemnumber,
patron_id => $recall_borrower->borrowernumber,
pickup_library_id => $recall_borrower->branchcode,
item_level => 1,
})->store;
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber );
is( $error, 'recalled', 'Cannot renew item that has been recalled' );
@ -1470,11 +1470,11 @@ subtest "CanBookBeRenewed tests" => sub {
# biblio-level requested recall: renewal not allowed
$recall = Koha::Recall->new({
biblionumber => $recall_item1->biblionumber,
itemnumber => undef,
borrowernumber => $recall_borrower->borrowernumber,
branchcode => $recall_borrower->branchcode,
item_level_recall => 0,
biblio_id => $recall_item1->biblionumber,
item_id => undef,
patron_id => $recall_borrower->borrowernumber,
pickup_library_id => $recall_borrower->branchcode,
item_level => 0,
})->store;
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber );
is( $error, 'recalled', 'Cannot renew item if biblio is recalled and has no item allocated' );
@ -1482,11 +1482,11 @@ subtest "CanBookBeRenewed tests" => sub {
# item-level and not this item: renewal allowed
$recall = Koha::Recall->new({
biblionumber => $recall_item2->biblionumber,
itemnumber => $recall_item2->itemnumber,
borrowernumber => $recall_borrower->borrowernumber,
branchcode => $recall_borrower->branchcode,
item_level_recall => 1,
biblio_id => $recall_item2->biblionumber,
item_id => $recall_item2->itemnumber,
patron_id => $recall_borrower->borrowernumber,
pickup_library_id => $recall_borrower->branchcode,
item_level => 1,
})->store;
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber );
is( $renewokay, 1, 'Can renew item if item-level recall on biblio is not on this item' );
@ -1494,11 +1494,11 @@ subtest "CanBookBeRenewed tests" => sub {
# biblio-level waiting recall: renewal allowed
$recall = Koha::Recall->new({
biblionumber => $recall_item1->biblionumber,
itemnumber => undef,
borrowernumber => $recall_borrower->borrowernumber,
branchcode => $recall_borrower->branchcode,
item_level_recall => 0,
biblio_id => $recall_item1->biblionumber,
item_id => undef,
patron_id => $recall_borrower->borrowernumber,
pickup_library_id => $recall_borrower->branchcode,
item_level => 0,
})->store;
$recall->set_waiting({ item => $recall_item1 });
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber );
@ -2104,44 +2104,44 @@ subtest 'AddIssue | recalls' => sub {
# checking out item that they have recalled
my $recall1 = Koha::Recall->new(
{ borrowernumber => $patron1->borrowernumber,
biblionumber => $item->biblionumber,
itemnumber => $item->itemnumber,
item_level_recall => 1,
branchcode => $patron1->branchcode,
{ patron_id => $patron1->borrowernumber,
biblio_id => $item->biblionumber,
item_id => $item->itemnumber,
item_level => 1,
pickup_library_id => $patron1->branchcode,
}
)->store;
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->recall_id } );
$recall1 = Koha::Recalls->find( $recall1->recall_id );
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->id } );
$recall1 = Koha::Recalls->find( $recall1->id );
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' );
AddReturn( $item->barcode, $item->homebranch );
# this item is has a recall request. cancel recall
my $recall2 = Koha::Recall->new(
{ borrowernumber => $patron2->borrowernumber,
biblionumber => $item->biblionumber,
itemnumber => $item->itemnumber,
item_level_recall => 1,
branchcode => $patron2->branchcode,
{ patron_id => $patron2->borrowernumber,
biblio_id => $item->biblionumber,
item_id => $item->itemnumber,
item_level => 1,
pickup_library_id => $patron2->branchcode,
}
)->store;
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->recall_id, cancel_recall => 'cancel' } );
$recall2 = Koha::Recalls->find( $recall2->recall_id );
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->id, cancel_recall => 'cancel' } );
$recall2 = Koha::Recalls->find( $recall2->id );
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' );
AddReturn( $item->barcode, $item->homebranch );
# this item is waiting to fulfill a recall. revert recall
my $recall3 = Koha::Recall->new(
{ borrowernumber => $patron2->borrowernumber,
biblionumber => $item->biblionumber,
itemnumber => $item->itemnumber,
item_level_recall => 1,
branchcode => $patron2->branchcode,
{ patron_id => $patron2->borrowernumber,
biblio_id => $item->biblionumber,
item_id => $item->itemnumber,
item_level => 1,
pickup_library_id => $patron2->branchcode,
}
)->store;
$recall3->set_waiting;
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->recall_id, cancel_recall => 'revert' } );
$recall3 = Koha::Recalls->find( $recall3->recall_id );
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->id, cancel_recall => 'revert' } );
$recall3 = Koha::Recalls->find( $recall3->id );
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' );
AddReturn( $item->barcode, $item->homebranch );
};
@ -4124,47 +4124,47 @@ subtest 'CanBookBeIssued | recalls' => sub {
# item-level recall
my $recall = Koha::Recall->new(
{ borrowernumber => $patron1->borrowernumber,
biblionumber => $item->biblionumber,
itemnumber => $item->itemnumber,
item_level_recall => 1,
branchcode => $patron1->branchcode,
{ patron_id => $patron1->borrowernumber,
biblio_id => $item->biblionumber,
item_id => $item->itemnumber,
item_level => 1,
pickup_library_id => $patron1->branchcode,
}
)->store;
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron2, $item->barcode, undef, undef, undef, undef );
is( $needsconfirmation->{RECALLED}->recall_id, $recall->recall_id, "Another patron has placed an item-level recall on this item" );
is( $needsconfirmation->{RECALLED}->id, $recall->id, "Another patron has placed an item-level recall on this item" );
$recall->set_cancelled;
# biblio-level recall
$recall = Koha::Recall->new(
{ borrowernumber => $patron1->borrowernumber,
biblionumber => $item->biblionumber,
itemnumber => undef,
item_level_recall => 0,
branchcode => $patron1->branchcode,
{ patron_id => $patron1->borrowernumber,
biblio_id => $item->biblionumber,
item_id => undef,
item_level => 0,
pickup_library_id => $patron1->branchcode,
}
)->store;
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron2, $item->barcode, undef, undef, undef, undef );
is( $needsconfirmation->{RECALLED}->recall_id, $recall->recall_id, "Another patron has placed a biblio-level recall and this item is eligible to fill it" );
is( $needsconfirmation->{RECALLED}->id, $recall->id, "Another patron has placed a biblio-level recall and this item is eligible to fill it" );
$recall->set_cancelled;
# biblio-level recall
$recall = Koha::Recall->new(
{ borrowernumber => $patron1->borrowernumber,
biblionumber => $item->biblionumber,
itemnumber => undef,
item_level_recall => 0,
branchcode => $patron1->branchcode,
{ patron_id => $patron1->borrowernumber,
biblio_id => $item->biblionumber,
item_id => undef,
item_level => 0,
pickup_library_id => $patron1->branchcode,
}
)->store;
$recall->set_waiting( { item => $item, expirationdate => dt_from_string() } );
my ( undef, undef, undef, $messages ) = CanBookBeIssued( $patron1, $item->barcode, undef, undef, undef, undef );
is( $messages->{RECALLED}, $recall->recall_id, "This book can be issued by this patron and they have placed a recall" );
is( $messages->{RECALLED}, $recall->id, "This book can be issued by this patron and they have placed a recall" );
$recall->set_cancelled;
};
@ -4204,25 +4204,25 @@ subtest 'AddReturn | recalls' => sub {
# this item can fill a recall with pickup at this branch
AddIssue( $patron1->unblessed, $item1->barcode );
my $recall1 = Koha::Recall->new(
{ borrowernumber => $patron2->borrowernumber,
biblionumber => $item1->biblionumber,
itemnumber => $item1->itemnumber,
item_level_recall => 1,
branchcode => $item1->homebranch,
{ patron_id => $patron2->borrowernumber,
biblio_id => $item1->biblionumber,
item_id => $item1->itemnumber,
item_level => 1,
pickup_library_id => $item1->homebranch,
}
)->store;
my ( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $item1->homebranch );
is( $messages->{RecallFound}->recall_id, $recall1->recall_id, "Recall found" );
is( $messages->{RecallFound}->id, $recall1->id, "Recall found" );
$recall1->set_cancelled;
# this item can fill a recall but needs transfer
AddIssue( $patron1->unblessed, $item1->barcode );
$recall1 = Koha::Recall->new(
{ borrowernumber => $patron2->borrowernumber,
biblionumber => $item1->biblionumber,
itemnumber => $item1->itemnumber,
item_level_recall => 1,
branchcode => $patron2->branchcode,
{ patron_id => $patron2->borrowernumber,
biblio_id => $item1->biblionumber,
item_id => $item1->itemnumber,
item_level => 1,
pickup_library_id => $patron2->branchcode,
}
)->store;
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $item1->homebranch );
@ -4232,16 +4232,16 @@ subtest 'AddReturn | recalls' => sub {
# this item is already in transit, do not ask to transfer
AddIssue( $patron1->unblessed, $item1->barcode );
$recall1 = Koha::Recall->new(
{ borrowernumber => $patron2->borrowernumber,
biblionumber => $item1->biblionumber,
itemnumber => $item1->itemnumber,
item_level_recall => 1,
branchcode => $patron2->branchcode,
{ patron_id => $patron2->borrowernumber,
biblio_id => $item1->biblionumber,
item_id => $item1->itemnumber,
item_level => 1,
pickup_library_id => $patron2->branchcode,
}
)->store;
$recall1->start_transfer;
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $patron2->branchcode );
is( $messages->{TransferredRecall}->recall_id, $recall1->recall_id, "In transit recall found" );
is( $messages->{TransferredRecall}->id, $recall1->id, "In transit recall found" );
$recall1->set_cancelled;
};

14
t/db_dependent/Circulation/CalcFine.t

@ -228,13 +228,13 @@ subtest 'Recall overdue fines' => sub {
);
my $recall = Koha::Recall->new({
borrowernumber => $patron->{borrowernumber},
recalldate => dt_from_string,
biblionumber => $item->biblionumber,
branchcode => $branch->{branchcode},
itemnumber => $item->itemnumber,
expirationdate => undef,
item_level_recall => 1
patron_id => $patron->{borrowernumber},
created_date => dt_from_string,
biblio_id => $item->biblionumber,
pickup_library_id => $branch->{branchcode},
item_id => $item->itemnumber,
expiration_date => undef,
item_level => 1
})->store;
$recall->set_overdue;

22
t/db_dependent/Circulation/transferbook.t

@ -158,11 +158,11 @@ subtest 'transfer already at destination' => sub {
# recalls
t::lib::Mocks::mock_preference('UseRecalls', 1);
my $recall = Koha::Recall->new(
{ biblionumber => $item->biblionumber,
itemnumber => $item->itemnumber,
item_level_recall => 1,
borrowernumber => $patron->borrowernumber,
branchcode => $library->branchcode,
{ biblio_id => $item->biblionumber,
item_id => $item->itemnumber,
item_level => 1,
patron_id => $patron->borrowernumber,
pickup_library_id => $library->branchcode,
}
)->store;
( $recall, $dotransfer, $messages ) = $recall->start_transfer;
@ -171,16 +171,16 @@ subtest 'transfer already at destination' => sub {
my $item2 = $builder->build_object({ class => 'Koha::Items' }); # this item will have a different holding branch to the pickup branch
$recall = Koha::Recall->new(
{ biblionumber => $item2->biblionumber,
itemnumber => $item2->itemnumber,
item_level_recall => 1,
borrowernumber => $patron->borrowernumber,
branchcode => $library->branchcode,
{ biblio_id => $item2->biblionumber,
item_id => $item2->itemnumber,
item_level => 1,
patron_id => $patron->borrowernumber,
pickup_library_id => $library->branchcode,
}
)->store;
( $recall, $dotransfer, $messages ) = $recall->start_transfer;
is( $dotransfer, 1, 'Transfer of recalled item succeeded' );
is( $messages->{RecallFound}->recall_id, $recall->recall_id, "We found the recall");
is( $messages->{RecallFound}->id, $recall->id, "We found the recall");
};
subtest 'transfer an issued item' => sub {

12
t/db_dependent/Holds.t

@ -1567,12 +1567,12 @@ subtest 'CanItemBeReserved / recall' => sub {
}
);
Koha::Recall->new({
borrowernumber => $patron1->borrowernumber,
biblionumber => $biblio1->biblionumber,
branchcode => $library1->branchcode,
itemnumber => $item1->itemnumber,
recalldate => '2020-05-04 10:10:10',
item_level_recall => 1,
patron_id => $patron1->borrowernumber,
biblio_id => $biblio1->biblionumber,
pickup_library_id => $library1->branchcode,
item_id => $item1->itemnumber,
created_date => '2020-05-04 10:10:10',
item_level => 1,
})->store;
is( CanItemBeReserved( $patron1, $item1, $library1->branchcode )->{status}, 'recall', "Can't reserve an item that they have already recalled" );

42
t/db_dependent/Koha/Biblio.t

@ -899,33 +899,33 @@ subtest 'Recalls tests' => sub {
t::lib::Mocks::mock_userenv({ patron => $patron1 });
my $recall1 = Koha::Recall->new(
{ borrowernumber => $patron1->borrowernumber,
recalldate => \'NOW()',
biblionumber => $biblio->biblionumber,
branchcode => $branchcode,
itemnumber => $item1->itemnumber,
expirationdate => undef,
item_level_recall => 1
{ patron_id => $patron1->borrowernumber,
created_date => \'NOW()',
biblio_id => $biblio->biblionumber,
pickup_library_id => $branchcode,
item_id => $item1->itemnumber,
expiration_date => undef,
item_level => 1
}
)->store;
my $recall2 = Koha::Recall->new(
{ borrowernumber => $patron2->borrowernumber,
recalldate => \'NOW()',
biblionumber => $biblio->biblionumber,
branchcode => $branchcode,
itemnumber => undef,
expirationdate => undef,
item_level_recall => 0
{ patron_id => $patron2->borrowernumber,
created_date => \'NOW()',
biblio_id => $biblio->biblionumber,
pickup_library_id => $branchcode,
item_id => undef,
expiration_date => undef,
item_level => 0
}
)->store;
my $recall3 = Koha::Recall->new(
{ borrowernumber => $patron3->borrowernumber,
recalldate => \'NOW()',
biblionumber => $biblio->biblionumber,
branchcode => $branchcode,
itemnumber => $item1->itemnumber,
expirationdate => undef,
item_level_recall => 1
{ patron_id => $patron3->borrowernumber,
created_date => \'NOW()',
biblio_id => $biblio->biblionumber,
pickup_library_id => $branchcode,
item_id => $item1->itemnumber,
expiration_date => undef,
item_level => 1
}
)->store;

78
t/db_dependent/Koha/Item.t

@ -1275,27 +1275,27 @@ subtest 'Recalls tests' => sub {
t::lib::Mocks::mock_preference('UseRecalls', 1);
my $recall1 = Koha::Recall->new(
{ borrowernumber => $patron1->borrowernumber,
recalldate => \'NOW()',
biblionumber => $biblio->biblionumber,
branchcode => $branchcode,
itemnumber => $item1->itemnumber,
expirationdate => undef,
item_level_recall => 1
{ patron_id => $patron1->borrowernumber,
created_date => \'NOW()',
biblio_id => $biblio->biblionumber,
pickup_library_id => $branchcode,
item_id => $item1->itemnumber,
expiration_date => undef,
item_level => 1
}
)->store;
my $recall2 = Koha::Recall->new(
{ borrowernumber => $patron2->borrowernumber,
recalldate => \'NOW()',
biblionumber => $biblio->biblionumber,
branchcode => $branchcode,
itemnumber => $item1->itemnumber,
expirationdate => undef,
item_level_recall => 1
{ patron_id => $patron2->borrowernumber,
created_date => \'NOW()',
biblio_id => $biblio->biblionumber,
pickup_library_id => $branchcode,
item_id => $item1->itemnumber,
expiration_date => undef,
item_level => 1
}
)->store;
is( $item1->recall->borrowernumber, $patron1->borrowernumber, 'Correctly returns most relevant recall' );
is( $item1->recall->patron_id, $patron1->borrowernumber, 'Correctly returns most relevant recall' );
$recall2->set_cancelled;
@ -1367,13 +1367,13 @@ subtest 'Recalls tests' => sub {
is( $item1->can_be_recalled({ patron => $patron1 }), 1, "Can recall item" );
$recall1 = Koha::Recall->new(
{ borrowernumber => $patron1->borrowernumber,
recalldate => \'NOW()',
biblionumber => $biblio->biblionumber,
branchcode => $branchcode,
itemnumber => undef,
expirationdate => undef,
item_level_recall => 0
{ patron_id => $patron1->borrowernumber,
created_date => \'NOW()',
biblio_id => $biblio->biblionumber,
pickup_library_id => $branchcode,
item_id => undef,
expiration_date => undef,
item_level => 0
}
)->store;
@ -1406,42 +1406,42 @@ subtest 'Recalls tests' => sub {
# check_recalls tests
$recall1 = Koha::Recall->new(
{ borrowernumber => $patron2->borrowernumber,
recalldate => \'NOW()',
biblionumber => $biblio->biblionumber,
branchcode => $branchcode,
itemnumber => $item1->itemnumber,
expirationdate => undef,
item_level_recall => 1
{ patron_id => $patron2->borrowernumber,
created_date => \'NOW()',
biblio_id => $biblio->biblionumber,
pickup_library_id => $branchcode,
item_id => $item1->itemnumber,
expiration_date => undef,
item_level => 1
}
)->store;
$recall2 = Koha::Recall->new(
{ borrowernumber => $patron1->borrowernumber,
recalldate => \'NOW()',
biblionumber => $biblio->biblionumber,
branchcode => $branchcode,
itemnumber => undef,
expirationdate => undef,
item_level_recall => 0
{ patron_id => $patron1->borrowernumber,
created_date => \'NOW()',
biblio_id => $biblio->biblionumber,
pickup_library_id => $branchcode,
item_id => undef,
expiration_date => undef,
item_level => 0
}
)->store;
$recall2->set_waiting( { item => $item1 } );
# return a waiting recall
my $check_recall = $item1->check_recalls;
is( $check_recall->borrowernumber, $patron1->borrowernumber, "Waiting recall is highest priority and returned" );
is( $check_recall->patron_id, $patron1->borrowernumber, "Waiting recall is highest priority and returned" );
$recall2->revert_waiting;
# return recall based on recalldate
$check_recall = $item1->check_recalls;
is( $check_recall->borrowernumber, $patron1->borrowernumber, "No waiting recall, so oldest recall is returned" );
is( $check_recall->patron_id, $patron1->borrowernumber, "No waiting recall, so oldest recall is returned" );
$recall1->set_cancelled;
# return a biblio-level recall
$check_recall = $item1->check_recalls;
is( $check_recall->borrowernumber, $patron1->borrowernumber, "Only remaining recall is returned" );
is( $check_recall->patron_id, $patron1->borrowernumber, "Only remaining recall is returned" );
$recall2->set_cancelled;

54
t/db_dependent/Koha/Patron.t

@ -1094,46 +1094,46 @@ subtest 'recalls() tests' => sub {
my $item2 = $builder->build_object({ class => 'Koha::Items' }, { value => { biblionumber => $biblio2->biblionumber } });
Koha::Recall->new(
{ biblionumber => $biblio1->biblionumber,
borrowernumber => $patron->borrowernumber,
itemnumber => $item1->itemnumber,
branchcode => $patron->branchcode,
recalldate => \'NOW()',
item_level_recall => 1,
{ biblio_id => $biblio1->biblionumber,
patron_id => $patron->borrowernumber,
item_id => $item1->itemnumber,
pickup_library_id => $patron->branchcode,
created_date => \'NOW()',
item_level => 1,
}
)->store;
Koha::Recall->new(
{ biblionumber => $biblio2->biblionumber,
borrowernumber => $patron->borrowernumber,
itemnumber => $item2->itemnumber,
branchcode => $patron->branchcode,
recalldate => \'NOW()',
item_level_recall => 1,
{ biblio_id => $biblio2->biblionumber,
patron_id => $patron->borrowernumber,
item_id => $item2->itemnumber,
pickup_library_id => $patron->branchcode,
created_date => \'NOW()',
item_level => 1,
}
)->store;
Koha::Recall->new(
{ biblionumber => $biblio1->biblionumber,
borrowernumber => $patron->borrowernumber,
itemnumber => undef,
branchcode => $patron->branchcode,
recalldate => \'NOW()',
item_level_recall => 0,
{ biblio_id => $biblio1->biblionumber,
patron_id => $patron->borrowernumber,
item_id => undef,
pickup_library_id => $patron->branchcode,
created_date => \'NOW()',
item_level => 0,
}
)->store;
my $recall = Koha::Recall->new(
{ biblionumber => $biblio1->biblionumber,
borrowernumber => $patron->borrowernumber,
itemnumber => undef,
branchcode => $patron->branchcode,
recalldate => \'NOW()',
item_level_recall => 0,
{ biblio_id => $biblio1->biblionumber,
patron_id => $patron->borrowernumber,
item_id => undef,
pickup_library_id => $patron->branchcode,
created_date => \'NOW()',
item_level => 0,
}
)->store;
$recall->set_cancelled;
is( $patron->recalls->count, 4, "Correctly gets this patron's recalls" );
is( $patron->recalls->filter_by_current->count, 3, "Correctly gets this patron's active recalls" );
is( $patron->recalls->filter_by_current->search( { biblionumber => $biblio1->biblionumber } )->count, 2, "Correctly gets this patron's active recalls on a specific biblio" );
is( $patron->recalls->count, 4, "Correctly gets this patron's recalls" );
is( $patron->recalls->filter_by_current->count, 3, "Correctly gets this patron's active recalls" );
is( $patron->recalls->filter_by_current->search( { biblio_id => $biblio1->biblionumber } )->count, 2, "Correctly gets this patron's active recalls on a specific biblio" );
$schema->storage->txn_rollback;
};

70
t/db_dependent/Koha/Recall.t

@ -54,7 +54,7 @@ my $category1 = $builder->build({ source => 'Category' })->{ categorycode };
my $patron1 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $category1, branchcode => $branch1 } });
my $patron2 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $category1, branchcode => $branch1 } });
t::lib::Mocks::mock_userenv({ patron => $patron1 });
my $old_recalls_count = Koha::Recalls->search({ old => 1 })->count;
my $old_recalls_count = Koha::Recalls->search({ completed => 1 })->count;
Koha::CirculationRules->set_rule({
branchcode => undef,
@ -68,14 +68,14 @@ my $overdue_date = dt_from_string->subtract( days => 4 );
C4::Circulation::AddIssue( $patron2->unblessed, $item1->barcode, $overdue_date );
my $recall1 = Koha::Recall->new({
borrowernumber => $patron1->borrowernumber,
recalldate => dt_from_string,
biblionumber => $biblio1->biblionumber,
branchcode => $branch1,
patron_id => $patron1->borrowernumber,
created_date => dt_from_string,
biblio_id => $biblio1->biblionumber,
pickup_library_id => $branch1,
status => 'requested',
itemnumber => $item1->itemnumber,
expirationdate => undef,
item_level_recall => 1
item_id => $item1->itemnumber,
expiration_date => undef,
item_level => 1
})->store;
is( $recall1->biblio->title, $biblio1->title, "Recall biblio relationship correctly linked" );
@ -93,13 +93,13 @@ $recall1->set_cancelled;
ok( $recall1->cancelled, "Recall is cancelled" );
my $recall2 = Koha::Recall->new({
borrowernumber => $patron1->borrowernumber,
recalldate => dt_from_string,
biblionumber => $biblio1->biblionumber,
branchcode => $branch1,
itemnumber => $item1->itemnumber,
expirationdate => undef,
item_level_recall => 1
patron_id => $patron1->borrowernumber,
created_date => dt_from_string,
biblio_id => $biblio1->biblionumber,
pickup_library_id => $branch1,
item_id => $item1->itemnumber,
expiration_date => undef,
item_level => 1
})->store;
Koha::CirculationRules->set_rule({
@ -135,17 +135,17 @@ ok( defined $notice, "Patron was notified to pick up waiting recall" );
$recall2->set_expired({ interface => 'COMMANDLINE' });
is( $recall2->expired, 1, "Recall has expired" );
my $old_recalls_count_now = Koha::Recalls->search({ old => 1 })->count;
my $old_recalls_count_now = Koha::Recalls->search({ completed => 1 })->count;
is( $old_recalls_count_now, $old_recalls_count + 2, "Recalls have been flagged as old when cancelled or expired" );
my $recall3 = Koha::Recall->new({
borrowernumber => $patron1->borrowernumber,
recalldate => dt_from_string,
biblionumber => $biblio1->biblionumber,
branchcode => $branch1,
itemnumber => $item1->itemnumber,
expirationdate => undef,
item_level_recall => 1
patron_id => $patron1->borrowernumber,
created_date => dt_from_string,
biblio_id => $biblio1->biblionumber,
pickup_library_id => $branch1,
item_id => $item1->itemnumber,
expiration_date => undef,
item_level => 1
})->store;
# test that recall gets T status
@ -154,7 +154,7 @@ ok( $recall3->in_transit, "Recall is in transit" );
$recall3->revert_transfer;
ok( $recall3->requested, "Recall transfer has been cancelled and the status reverted" );
is( $recall3->itemnumber, $item1->itemnumber, "Item persists for item-level recall" );
is( $recall3->item_id, $item1->itemnumber, "Item persists for item-level recall" );
# for testing purposes, pretend the item gets checked out
$recall3->set_fulfilled;
@ -162,27 +162,27 @@ ok( $recall3->fulfilled, "Recall has been fulfilled" );
C4::Circulation::AddIssue( $patron2->unblessed, $item1->barcode );
my $recall4 = Koha::Recall->new({
borrowernumber => $patron1->borrowernumber,
recalldate => dt_from_string,
biblionumber => $biblio1->biblionumber,
branchcode => $branch1,
itemnumber => undef,
expirationdate => undef,
item_level_recall => 0,
patron_id => $patron1->borrowernumber,
created_date => dt_from_string,
biblio_id => $biblio1->biblionumber,
pickup_library_id => $branch1,
item_id => undef,
expiration_date => undef,
item_level => 0
})->store;
ok( !defined $recall4->item, "No relevant item returned for a biblio-level recall" );
is( $recall4->checkout->itemnumber, $item1->itemnumber, "Return most relevant checkout for a biblio-level recall");
$recall4->set_waiting({ item => $item1, expirationdate => $expirationdate });
is( $recall4->itemnumber, $item1->itemnumber, "Item has been allocated to biblio-level recall" );
is( $recall4->item_id, $item1->itemnumber, "Item has been allocated to biblio-level recall" );
$recall4->revert_waiting;
ok( !defined $recall4->itemnumber, "Itemnumber has been removed from biblio-level recall when reverting waiting status" );
ok( !defined $recall4->item_id, "Itemnumber has been removed from biblio-level recall when reverting waiting status" );
$recall4->start_transfer({ item => $item1 });
is( $recall4->itemnumber, $item1->itemnumber, "Itemnumber saved to recall when item is transferred" );
is( $recall4->item_id, $item1->itemnumber, "Itemnumber saved to recall when item is transferred" );
$recall4->revert_transfer;
ok( !defined $recall4->itemnumber, "Itemnumber has been removed from biblio-level recall when reverting transfer status" );
ok( !defined $recall4->item_id, "Itemnumber has been removed from biblio-level recall when reverting transfer status" );
$schema->storage->txn_rollback();

24
t/db_dependent/Koha/Recalls.t

@ -106,7 +106,7 @@ ok( !defined $recall, "Can't add a recall without specifying a biblio" );
expirationdate => undef,
interface => 'COMMANDLINE',
});
is( $recall->branchcode, $branch2, "No pickup branch specified so patron branch used" );
is( $recall->pickup_library_id, $branch2, "No pickup branch specified so patron branch used" );
is( $due_interval, 5, "Recall due date interval defaults to 5 if not specified" );
Koha::CirculationRules->set_rule({
@ -134,7 +134,7 @@ is( $due_interval, 3, "Recall due date interval is based on circulation rules" )
expirationdate => undef,
interface => 'COMMANDLINE',
});
is( $recall->item_level_recall, 0, "No item provided so recall not flagged as item-level" );
is( $recall->item_level, 0, "No item provided so recall not flagged as item-level" );
my $expected_due_date = dt_from_string->add( days => 3 );
is( t::lib::Dates::compare( $recall->checkout->date_due, $expected_due_date ), 0, "Checkout due date has correctly been extended by recall_due_date_interval days" );
@ -146,19 +146,19 @@ is( $messages_count, 3, "RETURN_RECALLED_ITEM notice successfully sent to checko
my $message = Koha::Recalls->move_recall;
is( $message, 'no recall_id provided', "Can't move a recall without specifying which recall" );
$message = Koha::Recalls->move_recall({ recall_id => $recall->recall_id });
$message = Koha::Recalls->move_recall({ recall_id => $recall->id });
is( $message, 'no action provided', "No clear action to perform on recall" );
$message = Koha::Recalls->move_recall({ recall_id => $recall->recall_id, action => 'whatever' });
$message = Koha::Recalls->move_recall({ recall_id => $recall->id, action => 'whatever' });
is( $message, 'no action provided', "Legal action not provided to perform on recall" );
$recall->set_waiting({ item => $item1 });
ok( $recall->waiting, "Recall is waiting" );
Koha::Recalls->move_recall({ recall_id => $recall->recall_id, action => 'revert' });
$recall = Koha::Recalls->find( $recall->recall_id );
Koha::Recalls->move_recall({ recall_id => $recall->id, action => 'revert' });
$recall = Koha::Recalls->find( $recall->id );
ok( $recall->requested, "Recall reverted to requested with move_recall" );
Koha::Recalls->move_recall({ recall_id => $recall->recall_id, action => 'cancel' });
$recall = Koha::Recalls->find( $recall->recall_id );
Koha::Recalls->move_recall({ recall_id => $recall->id, action => 'cancel' });
$recall = Koha::Recalls->find( $recall->id );
ok( $recall->cancelled, "Recall cancelled with move_recall" );
( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
@ -169,8 +169,8 @@ ok( $recall->cancelled, "Recall cancelled with move_recall" );
expirationdate => undef,
interface => 'COMMANDLINE',
});
$message = Koha::Recalls->move_recall({ recall_id => $recall->recall_id, item => $item2, borrowernumber => $patron1->borrowernumber });
$recall = Koha::Recalls->find( $recall->recall_id );
$message = Koha::Recalls->move_recall({ recall_id => $recall->id, item => $item2, borrowernumber => $patron1->borrowernumber });
$recall = Koha::Recalls->find( $recall->id );
ok( $recall->fulfilled, "Recall fulfilled with move_recall" );
$schema->storage->txn_rollback();
@ -191,7 +191,7 @@ subtest 'filter_by_current() and filter_by_finished() tests' => sub {
my $recalls = Koha::Recalls->search(
{
recall_id => [
id => [
$in_transit->id,
$overdue->id,
$requested->id,
@ -201,7 +201,7 @@ subtest 'filter_by_current() and filter_by_finished() tests' => sub {
$fulfilled->id,
]
},
{ order_by => [ 'recall_id' ] }
{ order_by => [ 'id' ] }
);
is( $recalls->count, 7, 'Resultset count is correct' );

6
t/db_dependent/XSLT.t

@ -145,9 +145,9 @@ subtest 'buildKohaItemsNamespace status tests' => sub {
t::lib::Mocks::mock_preference('UseRecalls', 1);
my $recall = $builder->build_object({ class => 'Koha::Recalls', value => {
biblionumber => $item->biblionumber,
itemnumber => $item->itemnumber,
branchcode => $item->holdingbranch,
biblio_id => $item->biblionumber,
item_id => $item->itemnumber,
pickup_library_id => $item->holdingbranch,
}});
$recall->set_waiting;
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);

Loading…
Cancel
Save