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

(-)a/Koha/Notice/Message.pm (-6 / +5 lines)
Lines 156-173 sub stylesheets { Link Here
156
156
157
=head3 patron
157
=head3 patron
158
158
159
    my $patron = $message->patron;
159
    my $patron = $checkout->patron
160
160
161
Returns the Koha::Patron object for the recipient of the queued message
161
Return the patron by whom the checkout was done
162
162
163
=cut
163
=cut
164
164
165
sub patron {
165
sub patron {
166
    my ($self) = @_;
166
    my ($self) = @_;
167
167
    my $patron_rs = $self->_result->borrowernumber;
168
    $self->{_patron} ||= Koha::Patrons->find( $self->borrowernumber );
168
    return unless $patron_rs;
169
169
    return Koha::Patron->_new_from_dbic($patron_rs);
170
    return $self->{_patron};
171
}
170
}
172
171
173
=head3 type
172
=head3 type
(-)a/t/db_dependent/Koha/Notice/Message.t (-2 / +21 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::NoWarnings;
22
use Test::NoWarnings;
23
use Test::More tests => 4;
23
use Test::More tests => 5;
24
24
25
use C4::Letters qw( GetPreparedLetter EnqueueLetter );
25
use C4::Letters qw( GetPreparedLetter EnqueueLetter );
26
26
Lines 366-369 subtest 'stylesheets() tests' => sub { Link Here
366
    $schema->storage->txn_rollback;
366
    $schema->storage->txn_rollback;
367
};
367
};
368
368
369
subtest 'patron() tests' => sub {
370
371
    plan tests => 2;
372
373
    $schema->storage->txn_begin;
374
375
    my $patron  = $builder->build_object( { class => 'Koha::Patrons' } );
376
    my $message = $builder->build_object(
377
        {
378
            class => 'Koha::Notice::Messages',
379
            value => { borrowernumber => $patron->borrowernumber }
380
        }
381
    );
382
383
    is( ref( $message->patron ),          'Koha::Patron',          'Object type is correct' );
384
    is( $message->patron->borrowernumber, $patron->borrowernumber, 'Right patron linked' );
385
386
    $schema->storage->txn_rollback;
387
};
388
369
1;
389
1;
370
- 

Return to bug 33260