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

(-)a/Koha/Patron.pm (+14 lines)
Lines 647-652 sub merge_with { Link Here
647
}
647
}
648
648
649
649
650
=head3 messaging_preferences
651
652
    my $patron = Koha::Patrons->find($id);
653
    $patron->messaging_preferences();
654
655
=cut
656
657
sub messaging_preferences {
658
    my ( $self ) = @_;
659
660
    return Koha::Patron::MessagePreferences->search({
661
        borrowernumber => $self->borrowernumber,
662
    });
663
}
650
664
651
=head3 wants_check_for_previous_checkout
665
=head3 wants_check_for_previous_checkout
652
666
(-)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 => 6;
22
use Test::More tests => 7;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use Koha::Database;
25
use Koha::Database;
Lines 283-288 subtest 'add_enrolment_fee_if_needed() tests' => sub { Link Here
283
    };
283
    };
284
};
284
};
285
285
286
subtest 'messaging_preferences() tests' => sub {
287
    plan tests => 5;
288
289
    $schema->storage->txn_begin;
290
291
    my $mtt = $builder->build_object({
292
        class => 'Koha::Patron::MessagePreference::Transport::Types'
293
    });
294
    my $attribute = $builder->build_object({
295
        class => 'Koha::Patron::MessagePreference::Attributes'
296
    });
297
    my $branchcode     = $builder->build({
298
        source => 'Branch' })->{branchcode};
299
    my $letter = $builder->build_object({
300
        class => 'Koha::Notice::Templates',
301
        value => {
302
            branchcode => '',
303
            is_html => 0,
304
            message_transport_type => $mtt->message_transport_type
305
        }
306
    });
307
308
    Koha::Patron::MessagePreference::Transport->new({
309
        message_attribute_id   => $attribute->message_attribute_id,
310
        message_transport_type => $mtt->message_transport_type,
311
        is_digest              => 0,
312
        letter_module          => $letter->module,
313
        letter_code            => $letter->code,
314
    })->store;
315
316
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
317
318
    my $preference = Koha::Patron::MessagePreference->new({
319
        borrowernumber => $patron->borrowernumber,
320
        message_attribute_id => $attribute->message_attribute_id,
321
        wants_digest => 0,
322
        days_in_advance => undef,
323
    })->store;
324
325
    my $messaging_preferences = $patron->messaging_preferences();
326
    is($messaging_preferences->count, 1, 'Found one preference');
327
328
    my $messaging_preference = $messaging_preferences->next;
329
    is($messaging_preference->borrowernumber, $patron->borrowernumber);
330
    is($messaging_preference->message_attribute_id, $attribute->message_attribute_id);
331
    is($messaging_preference->wants_digest, 0);
332
    is($messaging_preference->days_in_advance, undef);
333
334
    $schema->storage->txn_rollback;
335
};
336
286
subtest 'to_api() tests' => sub {
337
subtest 'to_api() tests' => sub {
287
338
288
    plan tests => 6;
339
    plan tests => 6;
289
- 

Return to bug 17499