Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
sub guarantor {
my ( $self ) = @_;
+ return undef unless $self->guarantorid();
+
return Koha::Patrons->find( $self->guarantorid() );
}
my ( $self ) = @_;
my $guarantor = $self->guarantor;
- my $guarantorid = $guarantor ? $guarantor->borrowernumber : undef;
+
+ return undef unless $guarantor;
return Koha::Patrons->search(
{
guarantorid => {
'!=' => undef,
- '=' => $guarantorid,
+ '=' => $guarantor->id,
},
borrowernumber => {
'!=' => $self->borrowernumber,
subtest 'siblings' => sub {
plan tests => 7;
my $siblings = $new_patron_1->siblings;
- is( ref($siblings), 'Koha::Patrons', 'Koha::Patron->siblings should not crashed if the patron has not guarantor' );
+ is( $siblings, undef, 'Koha::Patron->siblings should not crashed if the patron has no guarantor' );
my $guarantee_1 = $builder->build( { source => 'Borrower', value => { guarantorid => $new_patron_1->borrowernumber } } );
my $retrieved_guarantee_1 = Koha::Patrons->find($guarantee_1);
$siblings = $retrieved_guarantee_1->siblings;