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

(-)a/t/db_dependent/api/v1/patrons.t (-2 / +39 lines)
Lines 27-32 use t::lib::Mocks; Link Here
27
use t::lib::Dates;
27
use t::lib::Dates;
28
28
29
use C4::Auth;
29
use C4::Auth;
30
use C4::Members::Messaging;
30
use Koha::Database;
31
use Koha::Database;
31
use Koha::DateUtils qw(dt_from_string output_pref);
32
use Koha::DateUtils qw(dt_from_string output_pref);
32
use Koha::Exceptions::Patron;
33
use Koha::Exceptions::Patron;
Lines 301-307 subtest 'add() tests' => sub { Link Here
301
    $schema->storage->txn_rollback;
302
    $schema->storage->txn_rollback;
302
303
303
    subtest 'librarian access tests' => sub {
304
    subtest 'librarian access tests' => sub {
304
        plan tests => 24;
305
        plan tests => 25;
305
306
306
        $schema->storage->txn_begin;
307
        $schema->storage->txn_begin;
307
308
Lines 539-544 subtest 'add() tests' => sub { Link Here
539
            is( $extended_attributes, 'a b c d e', 'Extended attributes are stored correctly');
540
            is( $extended_attributes, 'a b c d e', 'Extended attributes are stored correctly');
540
        };
541
        };
541
542
543
        subtest 'default patron messaging preferences handling' => sub {
544
545
            plan tests => 3;
546
547
            t::lib::Mocks::mock_preference( 'EnhancedMessagingPreferences', 1 );
548
549
            C4::Members::Messaging::SetMessagingPreference({
550
                categorycode => 'ST',
551
                message_attribute_id => 1,
552
                message_transport_types => ['email'],
553
                wants_digest => 1
554
            });
555
556
            my $patron_id = $t->post_ok(
557
                "//$userid:$password@/api/v1/patrons" => json => {
558
                    "firstname"   => "Nick",
559
                    "surname"     => "Clemens",
560
                    "address"     => "Somewhere",
561
                    "category_id" => "ST",
562
                    "city"        => "Smallville",
563
                    "library_id"  => "MPL",
564
                }
565
            )->status_is(201, 'Patron added')->tx->res->json->{patron_id};
566
567
            my $messaging_preferences = C4::Members::Messaging::GetMessagingPreferences({ borrowernumber => $patron_id, message_name => 'Item_Due' });
568
569
            is_deeply(
570
                $messaging_preferences,
571
                {
572
                    letter_code => 'DUEDGST',
573
                    wants_digest => 1,
574
                    transports => { email => 'DUEDGST' }
575
                } ,
576
                'Default messaging preferences set correctly'
577
            );
578
        };
579
542
        $schema->storage->txn_rollback;
580
        $schema->storage->txn_rollback;
543
    };
581
    };
544
};
582
};
545
- 

Return to bug 22993