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 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