use t::lib::Mocks;
use t::lib::TestBuilder;
-use C4::Biblio;
+use C4::Members;
use C4::Circulation;
use C4::Items;
-use C4::Members;
+use C4::Biblio;
use Koha::Database;
use Koha::Account::Lines;
use Koha::DateUtils;
my $branch;
my $context = Test::MockModule->new('C4::Context');
$context->mock( 'userenv', sub {
- return { branch => $branch }
+ return { branch => $branch, number => 1234, firstname => "Adam", surname => "Smaith" }
});
my $schema = Koha::Database->schema;
categorycode => '*',
itemtype => '*',
branchcode => '*',
- maxissueqty => 99,
issuelength => 1,
}
);
t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 1 );
AddReturn( $barcode, $branch );
- $item = GetItem( $itemnumber );
- is( $item->{location}, 'CART',
+ $item = Koha::Items->find( $itemnumber );
+ is( $item->location, 'CART',
"InProcessingToShelvingCart functions as intended" );
- $item->{location} = $location;
- ModItem( $item, undef, $itemnumber );
+ ModItem( {location => $location}, undef, $itemnumber );
t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 0 );
AddReturn( $barcode, $branch );
- $item = GetItem( $itemnumber );
- is( $item->{location}, $permanent_location,
+ $item = Koha::Items->find( $itemnumber );
+ is( $item->location, $permanent_location,
"InProcessingToShelvingCart functions as intended" );
};
"item-level itype recorded on statistics for return");
warning_like { AddIssue( $borrower, $item_without_itemtype->{ barcode } ) }
[qr/^item-level_itypes set but no itemtype set for item/,
+ qr/^item-level_itypes set but no itemtype set for item/,
+ qr/^item-level_itypes set but no itemtype set for item/,
+ qr/^item-level_itypes set but no itemtype set for item/,
+ qr/^item-level_itypes set but no itemtype set for item/,
qr/^item-level_itypes set but no itemtype set for item/],
'Item without itemtype set raises warning on AddIssue';
warning_like { AddReturn( $item_without_itemtype->{ barcode }, $branch ) }
};
subtest 'Handle ids duplication' => sub {
- plan tests => 6;
+ plan tests => 8;
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
t::lib::Mocks::mock_preference( 'CalculateFinesOnReturn', 1 );
$patron = Koha::Patrons->find( $patron->{borrowernumber} );
my $original_checkout = AddIssue( $patron->unblessed, $item->{barcode}, dt_from_string->subtract( days => 50 ) );
-
my $issue_id = $original_checkout->issue_id;
+ my $account_lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber, issue_id => $issue_id });
+ is( $account_lines->count, 1, '1 account line should exist for this issue_id' );
+ is( $account_lines->next->description, 'Rental', 'patron has been charged the rentalcharge' );
+ $account_lines->delete;
+
# Create an existing entry in old_issue
$builder->build({ source => 'OldIssue', value => { issue_id => $issue_id } });
is( $messages->{WasReturned}, 0, 'messages should have the WasReturned flag set to 0' );
is( $messages->{DataCorrupted}, 1, 'messages should have the DataCorrupted flag set to 1' );
- my $account_lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber, issue_id => $issue_id });
+ $account_lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber, issue_id => $issue_id });
is( $account_lines->count, 0, 'No account lines should exist for this issue_id, patron should not have been charged' );
is( Koha::Checkouts->find( $issue_id )->issue_id, $issue_id, 'The issues entry should not have been removed' );
};
subtest 'BlockReturnOfLostItems' => sub {
- plan tests => 3;
+ plan tests => 4;
my $biblio = $builder->build_object( { class => 'Koha::Biblios' } );
my $item = $builder->build_object(
{
is( $doreturn, 0, "With BlockReturnOfLostItems, a checkin of a lost item should be blocked");
is( $messages->{WasLost}, 1, "... and the WasLost flag should be set");
+ $item->discard_changes;
+ is( $item->itemlost, 1, "Item remains lost" );
+
t::lib::Mocks::mock_preference('BlockReturnOfLostItems', 0);
( $doreturn, $messages, $issue ) = AddReturn($item->barcode);
is( $doreturn, 1, "Without BlockReturnOfLostItems, a checkin of a lost item should not be blocked");