Bug 17973: Add the Koha::Checkout->item method
Test plan: prove t/db_dependent/Koha/Checkouts.t should return green Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
6f3732ee72
commit
2f763a9689
2 changed files with 23 additions and 1 deletions
|
@ -25,6 +25,7 @@ use Carp;
|
|||
use Koha::Database;
|
||||
use DateTime;
|
||||
use Koha::DateUtils;
|
||||
use Koha::Items;
|
||||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
|
@ -59,6 +60,20 @@ sub is_overdue {
|
|||
return $is_overdue;
|
||||
}
|
||||
|
||||
=head3 item
|
||||
|
||||
my $item = $checkout->item;
|
||||
|
||||
Return the checked out item
|
||||
|
||||
=cut
|
||||
|
||||
sub item {
|
||||
my ( $self ) = @_;
|
||||
my $item_rs = $self->_result->item;
|
||||
return Koha::Item->_new_from_dbic( $item_rs );
|
||||
}
|
||||
|
||||
=head3 type
|
||||
|
||||
=cut
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 5;
|
||||
use Test::More tests => 6;
|
||||
|
||||
use Koha::Checkouts;
|
||||
use Koha::Database;
|
||||
|
@ -86,6 +86,13 @@ subtest 'is_overdue' => sub {
|
|||
0, 'In Ten days, the item due yesterday will still be late' );
|
||||
};
|
||||
|
||||
subtest 'item' => sub {
|
||||
plan tests => 2;
|
||||
my $item = $retrieved_checkout_1->item;
|
||||
is( ref( $item ), 'Koha::Item', 'Koha::Checkout->item should return a Koha::Item' );
|
||||
is( $item->itemnumber, $item_1->{itemnumber}, 'Koha::Checkout->item should return the correct item' );
|
||||
};
|
||||
|
||||
$retrieved_checkout_1->delete;
|
||||
is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' );
|
||||
|
||||
|
|
Loading…
Reference in a new issue