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

(-)a/t/db_dependent/Koha/Patrons.t (-6 / +53 lines)
Lines 84-90 subtest 'library' => sub { Link Here
84
};
84
};
85
85
86
subtest 'guarantees' => sub {
86
subtest 'guarantees' => sub {
87
    plan tests => 8;
87
    plan tests => 13;
88
    my $guarantees = $new_patron_1->guarantees;
88
    my $guarantees = $new_patron_1->guarantees;
89
    is( ref($guarantees), 'Koha::Patrons', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' );
89
    is( ref($guarantees), 'Koha::Patrons', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' );
90
    is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee' );
90
    is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee' );
Lines 102-107 subtest 'guarantees' => sub { Link Here
102
    is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantees should return an array in a list context' );
102
    is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantees should return an array in a list context' );
103
    is( scalar(@guarantees), 2, 'new_patron_1 should have 2 guarantees' );
103
    is( scalar(@guarantees), 2, 'new_patron_1 should have 2 guarantees' );
104
    $_->delete for @guarantees;
104
    $_->delete for @guarantees;
105
106
    #Test return order of guarantees BZ 18635
107
    my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
108
    my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
109
110
    my $guarantor = $builder->build_object( { class => 'Koha::Patrons' } );
111
112
    my $order_guarantee1 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
113
            surname => 'Zebra',
114
            guarantorid => $guarantor->borrowernumber
115
        }
116
    })->borrowernumber;
117
118
    my $order_guarantee2 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
119
            surname => 'Yak',
120
            guarantorid => $guarantor->borrowernumber
121
        }
122
    })->borrowernumber;
123
124
    my $order_guarantee3 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
125
            surname => 'Xerus',
126
            firstname => 'Walrus',
127
            guarantorid => $guarantor->borrowernumber
128
        }
129
    })->borrowernumber;
130
131
    my $order_guarantee4 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
132
            surname => 'Xerus',
133
            firstname => 'Vulture',
134
            guarantorid => $guarantor->borrowernumber
135
        }
136
    })->borrowernumber;
137
138
    my $order_guarantee5 = $builder->build_object( { class => 'Koha::Patrons' ,  value => {
139
            surname => 'Xerus',
140
            firstname => 'Unicorn',
141
            guarantorid => $guarantor->borrowernumber
142
        }
143
    })->borrowernumber;
144
145
    $guarantees = $guarantor->guarantees();
146
147
    is( $guarantees->next()->borrowernumber, $order_guarantee5, "Return first guarantor alphabetically" );
148
    is( $guarantees->next()->borrowernumber, $order_guarantee4, "Return second guarantor alphabetically" );
149
    is( $guarantees->next()->borrowernumber, $order_guarantee3, "Return third guarantor alphabetically" );
150
    is( $guarantees->next()->borrowernumber, $order_guarantee2, "Return fourth guarantor alphabetically" );
151
    is( $guarantees->next()->borrowernumber, $order_guarantee1, "Return fifth guarantor alphabetically" );
105
};
152
};
106
153
107
subtest 'category' => sub {
154
subtest 'category' => sub {
Lines 997-1002 subtest 'libraries_where_can_see_patrons + can_see_patron_infos + search_limited Link Here
997
    #   + library_12
1044
    #   + library_12
998
    # group2
1045
    # group2
999
    #   + library21
1046
    #   + library21
1047
    $nb_of_patrons = Koha::Patrons->search->count;
1000
    my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } )->store;
1048
    my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } )->store;
1001
    my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } )->store;
1049
    my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } )->store;
1002
    my $library_11 = $builder->build( { source => 'Branch' } );
1050
    my $library_11 = $builder->build( { source => 'Branch' } );
Lines 1067-1074 subtest 'libraries_where_can_see_patrons + can_see_patron_infos + search_limited Link Here
1067
        plan tests => 6;
1115
        plan tests => 6;
1068
1116
1069
        set_logged_in_user( $patron_11_1 );
1117
        set_logged_in_user( $patron_11_1 );
1070
        my $total_number_of_patrons = $nb_of_patrons + 6; # 2 created before + 4 for these subtests
1118
        my $total_number_of_patrons = $nb_of_patrons + 4; #we added four in these tests
1071
        is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons');
1119
        is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons' );
1072
        is( Koha::Patrons->search_limited->count, $total_number_of_patrons, 'patron_11_1 is allowed to see all patrons' );
1120
        is( Koha::Patrons->search_limited->count, $total_number_of_patrons, 'patron_11_1 is allowed to see all patrons' );
1073
1121
1074
        set_logged_in_user( $patron_11_2 );
1122
        set_logged_in_user( $patron_11_2 );
Lines 1356-1364 subtest 'generate_userid' => sub { Link Here
1356
    $patron_2->delete;
1404
    $patron_2->delete;
1357
};
1405
};
1358
1406
1359
1407
$nb_of_patrons = Koha::Patrons->search->count;
1360
$retrieved_patron_1->delete;
1408
$retrieved_patron_1->delete;
1361
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
1409
is( Koha::Patrons->search->count, $nb_of_patrons - 1, 'Delete should have deleted the patron' );
1362
1410
1363
subtest 'Log cardnumber change' => sub {
1411
subtest 'Log cardnumber change' => sub {
1364
    plan tests => 3;
1412
    plan tests => 3;
1365
- 

Return to bug 18635