@@ -, +, @@ --- t/db_dependent/Circulation/Returns.t | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) --- a/t/db_dependent/Circulation/Returns.t +++ a/t/db_dependent/Circulation/Returns.t @@ -1,5 +1,6 @@ use Modern::Perl; -use Test::More tests => 2; + +use Test::More tests => 3; use t::lib::Mocks; use C4::Biblio; @@ -8,6 +9,7 @@ use C4::Items; use C4::Members; use Koha::Database; use Koha::DateUtils; +use Koha::OldIssues; use t::lib::TestBuilder; @@ -56,3 +58,31 @@ is( $item->{location}, 'TEST', "InProcessingToShelvingCart functions as intended sub Mock_userenv { return { branch => $library->{branchcode} }; } + +subtest 'Handle ids duplication' => sub { + plan tests => 1; + + my $biblio = $builder->build( { source => 'Biblio' } ); + my $item = $builder->build( + { + source => 'Item', + value => { + biblionumber => $biblio->{biblionumber}, + notforloan => 0, + itemlost => 0, + withdrawn => 0, + + } + } + ); + my $patron = $builder->build({source => 'Borrower'}); + + my $checkout = AddIssue( $patron, $item->{barcode} ); + $builder->build({ source => 'OldIssue', value => { issue_id => $checkout->issue_id } }); + + my @a = AddReturn( $item->{barcode} ); + my $old_checkout = Koha::Old::Checkouts->find( $checkout->issue_id ); + isnt( $old_checkout->itemnumber, $item->{itemnumber}, 'If an item is checked-in, it should be moved to old_issues even if the issue_id already existed in the table' ); +}; + +1; --