Bug 27808: Add unit tests

Signed-off-by: Lisette Scheer <lisettes@latahlibrary.org>

Signed-off-by: Marti Fuerst <mfuerst@hmcpl.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 36c49aa2a8)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Kyle M Hall 2021-02-26 09:44:30 -05:00 committed by Fridolin Somers
parent a557bde38e
commit 1f8bc45f2d
1 changed files with 30 additions and 1 deletions

View File

@ -18,7 +18,7 @@
use Modern::Perl;
use utf8;
use Test::More tests => 52;
use Test::More tests => 53;
use Test::Exception;
use Test::MockModule;
use Test::Deep qw( cmp_deeply );
@ -4726,6 +4726,35 @@ subtest 'AddIssue records staff who checked out item if appropriate' => sub {
is( $issue->issuer, $issuer->{borrowernumber}, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
};
subtest "Item's onloan value should be set if checked out item is checked out to a different patron" => sub {
plan tests => 2;
my $library_1 = $builder->build_object( { class => 'Koha::Libraries' } );
my $patron_1 = $builder->build_object(
{
class => 'Koha::Patrons',
value => { branchcode => $library_1->branchcode }
}
);
my $patron_2 = $builder->build_object(
{
class => 'Koha::Patrons',
value => { branchcode => $library_1->branchcode }
}
);
my $item = $builder->build_sample_item(
{
library => $library_1->branchcode,
}
);
AddIssue( $patron_1->unblessed, $item->barcode );
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" );
AddIssue( $patron_2->unblessed, $item->barcode );
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" );
};
$schema->storage->txn_rollback;
C4::Context->clear_syspref_cache();
$branches = Koha::Libraries->search();