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

(-)a/t/db_dependent/Koha/Patrons.t (-1 / +44 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 29;
22
use Test::More tests => 30;
23
use Test::Warn;
23
use Test::Warn;
24
use Time::Fake;
24
use Time::Fake;
25
use DateTime;
25
use DateTime;
Lines 529-534 subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub { Link Here
529
    $module->unmock('userenv');
529
    $module->unmock('userenv');
530
};
530
};
531
531
532
subtest 'get_routinglists' => sub {
533
    plan tests => 5;
534
535
    my $biblio = Koha::Biblio->new()->store();
536
    my $subscription = Koha::Subscription->new({
537
        biblionumber => $biblio->biblionumber,
538
        }
539
    )->store;
540
541
    my $patron = $builder->build( { source => 'Borrower' } );
542
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
543
544
    is( $patron->get_routinglists, 0, 'Retrieves correct number of routing lists: 0' );
545
546
    my $routinglist_count = Koha::Subscription::Routinglists->count;
547
    my $routinglist = Koha::Subscription::Routinglist->new({
548
        borrowernumber   => $patron->borrowernumber,
549
        ranking          => 5,
550
        subscriptionid   => $subscription->subscriptionid
551
    })->store;
552
553
    is ($patron->get_routinglists, 1, "Retrieves correct number of routing lists: 1");
554
555
    my @routinglists = $patron->get_routinglists;
556
    is ($routinglists[0]->ranking, 5, "Retrieves ranking: 5");
557
    is( ref($routinglists[0]),   'Koha::Subscription::Routinglist', 'get_routinglists returns Koha::Subscription::Routinglist objects' );
558
559
    my $subscription2 = Koha::Subscription->new({
560
        biblionumber => $biblio->biblionumber,
561
        }
562
    )->store;
563
    my $routinglist2 = Koha::Subscription::Routinglist->new({
564
        borrowernumber   => $patron->borrowernumber,
565
        ranking          => 1,
566
        subscriptionid   => $subscription2->subscriptionid
567
    })->store;
568
569
    is ($patron->get_routinglists, 2, "Retrieves correct number of routing lists: 2");
570
571
    $patron->delete; # Clean up for later tests
572
573
};
574
532
subtest 'get_age' => sub {
575
subtest 'get_age' => sub {
533
    plan tests => 7;
576
    plan tests => 7;
534
577
(-)a/t/db_dependent/Koha/Subscription/Routinglists.t (-1 / +67 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WIT HOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
use t::lib::TestBuilder;
22
23
use C4::Biblio;
24
25
use Koha::Database;
26
use Koha::Patrons;
27
use Koha::Subscriptions;
28
use Koha::Subscription::Routinglists;
29
30
my $schema  = Koha::Database->new->schema;
31
my $builder = t::lib::TestBuilder->new;
32
33
subtest 'new() tests' => sub {
34
    plan tests => 4;
35
36
    $schema->storage->txn_begin;
37
38
    my $biblio = Koha::Biblio->new()->store();
39
    my $subscription = Koha::Subscription->new({
40
        biblionumber => $biblio->biblionumber,
41
        }
42
    )->store;
43
44
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
45
    my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->id } });
46
47
    my $routinglist_count = Koha::Subscription::Routinglists->count;
48
    my $routinglist = Koha::Subscription::Routinglist->new({
49
        borrowernumber   => $patron->borrowernumber,
50
        ranking          => 1,
51
        subscriptionid   => $subscription->subscriptionid
52
    })->store;
53
54
    is( Koha::Subscription::Routinglists->search->count, $routinglist_count +1, 'One routing list added' );
55
56
    my $retrieved_routinglist = Koha::Subscription::Routinglists->find( $routinglist->routingid );
57
    is ( $retrieved_routinglist->routingid, $routinglist->routingid, "Find a routing list by id returns the correct routing list");
58
59
    $routinglist->ranking(4)->update;
60
    is ( $routinglist->ranking, 4, "Routing list ranking has been updated");
61
62
    $routinglist->delete;
63
    is ( Koha::Subscription::Routinglists->search->count, $routinglist_count, 'One subscription list deleted' );
64
65
};
66
67
$schema->storage->txn_rollback;

Return to bug 20400