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

(-)a/Koha/Patron.pm (+14 lines)
Lines 667-672 sub merge_with { Link Here
667
}
667
}
668
668
669
669
670
=head3 messaging_preferences
671
672
    my $patron = Koha::Patrons->find($id);
673
    $patron->messaging_preferences();
674
675
=cut
676
677
sub messaging_preferences {
678
    my ( $self ) = @_;
679
680
    return Koha::Patron::MessagePreferences->search({
681
        borrowernumber => $self->borrowernumber,
682
    });
683
}
670
684
671
=head3 wants_check_for_previous_checkout
685
=head3 wants_check_for_previous_checkout
672
686
(-)a/t/db_dependent/Koha/Patron.t (-2 / +52 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 19;
22
use Test::More tests => 20;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 287-292 subtest 'add_enrolment_fee_if_needed() tests' => sub { Link Here
287
    };
287
    };
288
};
288
};
289
289
290
subtest 'messaging_preferences() tests' => sub {
291
    plan tests => 5;
292
293
    $schema->storage->txn_begin;
294
295
    my $mtt = $builder->build_object({
296
        class => 'Koha::Patron::MessagePreference::Transport::Types'
297
    });
298
    my $attribute = $builder->build_object({
299
        class => 'Koha::Patron::MessagePreference::Attributes'
300
    });
301
    my $branchcode     = $builder->build({
302
        source => 'Branch' })->{branchcode};
303
    my $letter = $builder->build_object({
304
        class => 'Koha::Notice::Templates',
305
        value => {
306
            branchcode => '',
307
            is_html => 0,
308
            message_transport_type => $mtt->message_transport_type
309
        }
310
    });
311
312
    Koha::Patron::MessagePreference::Transport->new({
313
        message_attribute_id   => $attribute->message_attribute_id,
314
        message_transport_type => $mtt->message_transport_type,
315
        is_digest              => 0,
316
        letter_module          => $letter->module,
317
        letter_code            => $letter->code,
318
    })->store;
319
320
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
321
322
    my $preference = Koha::Patron::MessagePreference->new({
323
        borrowernumber => $patron->borrowernumber,
324
        message_attribute_id => $attribute->message_attribute_id,
325
        wants_digest => 0,
326
        days_in_advance => undef,
327
    })->store;
328
329
    my $messaging_preferences = $patron->messaging_preferences();
330
    is($messaging_preferences->count, 1, 'Found one preference');
331
332
    my $messaging_preference = $messaging_preferences->next;
333
    is($messaging_preference->borrowernumber, $patron->borrowernumber);
334
    is($messaging_preference->message_attribute_id, $attribute->message_attribute_id);
335
    is($messaging_preference->wants_digest, 0);
336
    is($messaging_preference->days_in_advance, undef);
337
338
    $schema->storage->txn_rollback;
339
};
340
290
subtest 'to_api() tests' => sub {
341
subtest 'to_api() tests' => sub {
291
342
292
    plan tests => 6;
343
    plan tests => 6;
293
- 

Return to bug 17499