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

(-)a/Koha/Notice/Message.pm (-6 / +5 lines)
Lines 158-175 sub stylesheets { Link Here
158
158
159
=head3 patron
159
=head3 patron
160
160
161
    my $patron = $message->patron;
161
    my $patron = $checkout->patron
162
162
163
Returns the Koha::Patron object for the recipient of the queued message
163
Return the patron by whom the checkout was done
164
164
165
=cut
165
=cut
166
166
167
sub patron {
167
sub patron {
168
    my ($self) = @_;
168
    my ($self) = @_;
169
169
    my $patron_rs = $self->_result->borrowernumber;
170
    $self->{_patron} ||= Koha::Patrons->find( $self->borrowernumber );
170
    return unless $patron_rs;
171
171
    return Koha::Patron->_new_from_dbic($patron_rs);
172
    return $self->{_patron};
173
}
172
}
174
173
175
=head3 type
174
=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