View | Details | Raw Unified | Return to bug 33260
Collapse All | Expand All

(-)a/Koha/Notice/Message.pm (-6 / +5 lines)
Lines 126-143 sub restrict_patron_when_notice_fails { Link Here
126
126
127
=head3 patron
127
=head3 patron
128
128
129
    my $patron = $message->patron;
129
    my $patron = $checkout->patron
130
130
131
Returns the Koha::Patron object for the recipient of the queued message
131
Return the patron by whom the checkout was done
132
132
133
=cut
133
=cut
134
134
135
sub patron {
135
sub patron {
136
    my ($self) = @_;
136
    my ($self) = @_;
137
137
    my $patron_rs = $self->_result->borrowernumber;
138
    $self->{_patron} ||= Koha::Patrons->find( $self->borrowernumber );
138
    return unless $patron_rs;
139
139
    return Koha::Patron->_new_from_dbic($patron_rs);
140
    return $self->{_patron};
141
}
140
}
142
141
143
=head3 type
142
=head3 type
(-)a/t/db_dependent/Koha/Notice/Message.t (-1 / +20 lines)
Lines 219-222 WRAPPED Link Here
219
    $schema->storage->txn_rollback;
219
    $schema->storage->txn_rollback;
220
};
220
};
221
221
222
subtest 'patron() tests' => sub {
223
224
    plan tests => 2;
225
226
    $schema->storage->txn_begin;
227
228
    my $patron  = $builder->build_object( { class => 'Koha::Patrons' } );
229
    my $message = $builder->build_object(
230
        {
231
            class => 'Koha::Notice::Messages',
232
            value => { borrowernumber => $patron->borrowernumber }
233
        }
234
    );
235
236
    is( ref( $message->patron ),          'Koha::Patron',          'Object type is correct' );
237
    is( $message->patron->borrowernumber, $patron->borrowernumber, 'Right patron linked' );
238
239
    $schema->storage->txn_rollback;
240
};
241
222
1;
242
1;
223
- 

Return to bug 33260