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

(-)a/t/db_dependent/Patron.t (-1 / +95 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
# WITHOUT 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 => 3;
21
use Test::Warn;
22
23
use C4::Context;
24
use Koha::Database;
25
use Koha::DateUtils;
26
27
use t::lib::TestBuilder;
28
29
BEGIN {
30
    use_ok('Koha::Objects');
31
    use_ok('Koha::Patron');
32
}
33
34
# Start transaction
35
my $database = Koha::Database->new();
36
my $schema = $database->schema();
37
38
subtest 'Patron->guarantees' => sub {
39
    plan tests => 5;
40
41
    $schema->storage->txn_begin();
42
43
    my $builder = t::lib::TestBuilder->new;
44
45
    my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
46
    my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
47
48
    my $guarantor = $builder->build_object( { class => 'Koha::Patrons' } );
49
50
    my $guarantee1 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
51
            surname => 'Zebra',
52
            guarantorid => $guarantor->borrowernumber
53
        }
54
    })->borrowernumber;
55
56
    my $guarantee2 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
57
            surname => 'Yak',
58
            guarantorid => $guarantor->borrowernumber
59
        }
60
    })->borrowernumber;
61
62
    my $guarantee3 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
63
            surname => 'Xerus',
64
            firstname => 'Walrus',
65
            guarantorid => $guarantor->borrowernumber
66
        }
67
    })->borrowernumber;
68
69
    my $guarantee4 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
70
            surname => 'Xerus',
71
            firstname => 'Vulture',
72
            guarantorid => $guarantor->borrowernumber
73
        }
74
    })->borrowernumber;
75
76
    my $guarantee5 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
77
            surname => 'Xerus',
78
            firstname => 'Unicorn',
79
            guarantorid => $guarantor->borrowernumber
80
        }
81
    })->borrowernumber;
82
83
    my $guarantees = $guarantor->guarantees();
84
85
    is( $guarantees->next()->borrowernumber, $guarantee5, "Return first guarantor alphabetically" );
86
    is( $guarantees->next()->borrowernumber, $guarantee4, "Return second guarantor alphabetically" );
87
    is( $guarantees->next()->borrowernumber, $guarantee3, "Return third guarantor alphabetically" );
88
    is( $guarantees->next()->borrowernumber, $guarantee2, "Return fourth guarantor alphabetically" );
89
    is( $guarantees->next()->borrowernumber, $guarantee1, "Return fifth guarantor alphabetically" );
90
91
    $schema->storage->txn_rollback();
92
93
};
94
95
1;

Return to bug 18635