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

(-)a/Koha/Notice/Message.pm (-6 / +5 lines)
Lines 90-107 EOS Link Here
90
90
91
=head3 patron
91
=head3 patron
92
92
93
    my $patron = $message->patron;
93
    my $patron = $checkout->patron
94
94
95
Returns the Koha::Patron object for the recipient of the queued message
95
Return the patron by whom the checkout was done
96
96
97
=cut
97
=cut
98
98
99
sub patron {
99
sub patron {
100
    my ($self) = @_;
100
    my ($self) = @_;
101
101
    my $patron_rs = $self->_result->borrowernumber;
102
    $self->{_patron} ||= Koha::Patrons->find( $self->borrowernumber );
102
    return unless $patron_rs;
103
103
    return Koha::Patron->_new_from_dbic($patron_rs);
104
    return $self->{_patron};
105
}
104
}
106
105
107
=head3 type
106
=head3 type
(-)a/t/db_dependent/Koha/Notice/Message.t (-1 / +20 lines)
Lines 222-225 WRAPPED Link Here
222
    $schema->storage->txn_rollback;
222
    $schema->storage->txn_rollback;
223
};
223
};
224
224
225
subtest 'patron() tests' => sub {
226
227
    plan tests => 2;
228
229
    $schema->storage->txn_begin;
230
231
    my $patron  = $builder->build_object( { class => 'Koha::Patrons' } );
232
    my $message = $builder->build_object(
233
        {
234
            class => 'Koha::Notice::Messages',
235
            value => { borrowernumber => $patron->borrowernumber }
236
        }
237
    );
238
239
    is( ref( $message->patron ),          'Koha::Patron',          'Object type is correct' );
240
    is( $message->patron->borrowernumber, $patron->borrowernumber, 'Right patron linked' );
241
242
    $schema->storage->txn_rollback;
243
};
244
225
1;
245
1;
226
- 

Return to bug 33260