Bug 18242: 16.05 version - [SOLUTION 2]Add tests

Signed-off-by: Mason James <mtj@kohaaloha.com>
This commit is contained in:
Jonathan Druart 2017-03-09 16:41:31 -03:00 committed by Mason James
parent 826f33b719
commit bcdf0ba348
1 changed files with 31 additions and 1 deletions

View File

@ -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;