Bug 39600: Add Koha::Patron->ill_requests() accessor
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Tadeusz „tadzik” Sośnierz <tadeusz@sosnierz.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
a715c695f7
commit
87b0773d5f
|
|
@ -46,6 +46,7 @@ use Koha::Encryption;
|
|||
use Koha::Exceptions;
|
||||
use Koha::Exceptions::Password;
|
||||
use Koha::Holds;
|
||||
use Koha::ILL::Requests;
|
||||
use Koha::Old::Checkouts;
|
||||
use Koha::OverdueRules;
|
||||
use Koha::Patron::Attributes;
|
||||
|
|
@ -1481,6 +1482,19 @@ sub checkouts {
|
|||
return Koha::Checkouts->_new_from_dbic($checkouts);
|
||||
}
|
||||
|
||||
=head3 ill_requests
|
||||
|
||||
my $ill_requests = $patron->ill_requests();
|
||||
|
||||
Method that returns the related I<Koha::ILL::Requests> iterator.
|
||||
|
||||
=cut
|
||||
|
||||
sub ill_requests {
|
||||
my ($self) = @_;
|
||||
return Koha::ILL::Requests->_new_from_dbic( scalar $self->_result->ill_requests );
|
||||
}
|
||||
|
||||
=head3 pending_checkouts
|
||||
|
||||
my $pending_checkouts = $patron->pending_checkouts
|
||||
|
|
|
|||
|
|
@ -2230,6 +2230,13 @@ __PACKAGE__->add_columns(
|
|||
'+protected' => { is_boolean => 1 },
|
||||
);
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"ill_requests",
|
||||
"Koha::Schema::Result::Illrequest",
|
||||
{ "foreign.borrowernumber" => "self.borrowernumber" },
|
||||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
=head2 koha_objects_class
|
||||
|
||||
Missing POD for koha_objects_class.
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 38;
|
||||
use Test::More tests => 39;
|
||||
use Test::Exception;
|
||||
use Test::Warn;
|
||||
use Time::Fake;
|
||||
|
|
@ -2846,3 +2846,25 @@ subtest 'preferred_name' => sub {
|
|||
is( $patron->preferred_name, "Preferred again", "Preferred name set on update when passed" );
|
||||
|
||||
};
|
||||
|
||||
subtest 'ill_requests() tests' => sub {
|
||||
|
||||
plan tests => 3;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
|
||||
my $reqs_rs = $patron->ill_requests();
|
||||
is( ref($reqs_rs), 'Koha::ILL::Requests', 'Returned object type is correct' );
|
||||
is( $reqs_rs->count, 0, 'No linked ILL requests for the patron' );
|
||||
|
||||
# add two requests
|
||||
$builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->id } } );
|
||||
$builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->id } } );
|
||||
|
||||
$reqs_rs = $patron->ill_requests();
|
||||
is( $reqs_rs->count, 2, 'Two linked ILL requests for the patron' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue