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

(-)a/Koha/Patron.pm (+14 lines)
Lines 681-686 sub merge_with { Link Here
681
}
681
}
682
682
683
683
684
=head3 messaging_preferences
685
686
    my $patron = Koha::Patrons->find($id);
687
    $patron->messaging_preferences();
688
689
=cut
690
691
sub messaging_preferences {
692
    my ( $self ) = @_;
693
694
    return Koha::Patron::MessagePreferences->search({
695
        borrowernumber => $self->borrowernumber,
696
    });
697
}
684
698
685
=head3 wants_check_for_previous_checkout
699
=head3 wants_check_for_previous_checkout
686
700
(-)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 => 24;
22
use Test::More tests => 25;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 288-293 subtest 'add_enrolment_fee_if_needed() tests' => sub { Link Here
288
    };
288
    };
289
};
289
};
290
290
291
subtest 'messaging_preferences() tests' => sub {
292
    plan tests => 5;
293
294
    $schema->storage->txn_begin;
295
296
    my $mtt = $builder->build_object({
297
        class => 'Koha::Patron::MessagePreference::Transport::Types'
298
    });
299
    my $attribute = $builder->build_object({
300
        class => 'Koha::Patron::MessagePreference::Attributes'
301
    });
302
    my $branchcode     = $builder->build({
303
        source => 'Branch' })->{branchcode};
304
    my $letter = $builder->build_object({
305
        class => 'Koha::Notice::Templates',
306
        value => {
307
            branchcode => '',
308
            is_html => 0,
309
            message_transport_type => $mtt->message_transport_type
310
        }
311
    });
312
313
    Koha::Patron::MessagePreference::Transport->new({
314
        message_attribute_id   => $attribute->message_attribute_id,
315
        message_transport_type => $mtt->message_transport_type,
316
        is_digest              => 0,
317
        letter_module          => $letter->module,
318
        letter_code            => $letter->code,
319
    })->store;
320
321
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
322
323
    my $preference = Koha::Patron::MessagePreference->new({
324
        borrowernumber => $patron->borrowernumber,
325
        message_attribute_id => $attribute->message_attribute_id,
326
        wants_digest => 0,
327
        days_in_advance => undef,
328
    })->store;
329
330
    my $messaging_preferences = $patron->messaging_preferences();
331
    is($messaging_preferences->count, 1, 'Found one preference');
332
333
    my $messaging_preference = $messaging_preferences->next;
334
    is($messaging_preference->borrowernumber, $patron->borrowernumber);
335
    is($messaging_preference->message_attribute_id, $attribute->message_attribute_id);
336
    is($messaging_preference->wants_digest, 0);
337
    is($messaging_preference->days_in_advance, undef);
338
339
    $schema->storage->txn_rollback;
340
};
341
291
subtest 'to_api() tests' => sub {
342
subtest 'to_api() tests' => sub {
292
343
293
    plan tests => 6;
344
    plan tests => 6;
294
- 

Return to bug 17499