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

(-)a/t/db_dependent/Circulation/AnonymiseIssueHistory.t (-313 lines)
Lines 1-313 Link Here
1
2
#!/usr/bin/perl
3
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# Koha is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
19
use Modern::Perl;
20
21
use Test::More tests => 5;
22
23
use C4::Context;
24
use C4::Circulation;
25
26
use Koha::Database;
27
use Koha::Items;
28
29
use t::lib::Mocks;
30
use t::lib::TestBuilder;
31
32
my $schema  = Koha::Database->new->schema;
33
$schema->storage->txn_begin;
34
35
my $builder = t::lib::TestBuilder->new;
36
37
# TODO create a subroutine in t::lib::Mocks
38
my $branch = $builder->build({ source => 'Branch' });
39
my $userenv_patron = $builder->build({
40
    source => 'Borrower',
41
    value  => { branchcode => $branch->{branchcode} },
42
});
43
C4::Context->_new_userenv('DUMMY SESSION');
44
C4::Context->set_userenv(
45
    $userenv_patron->{borrowernumber},
46
    $userenv_patron->{userid},
47
    'usercnum', 'First name', 'Surname',
48
    $branch->{branchcode},
49
    $branch->{branchname},
50
    0,
51
);
52
53
my $anonymous = $builder->build( { source => 'Borrower', }, );
54
55
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->{borrowernumber} );
56
57
subtest 'patron privacy is 1 (default)' => sub {
58
    plan tests => 4;
59
    t::lib::Mocks::mock_preference('IndependentBranches', 0);
60
    my $patron = $builder->build(
61
        {   source => 'Borrower',
62
            value  => { privacy => 1, branchcode => $userenv_patron->{branchcode} }
63
        }
64
    );
65
    my $item = $builder->build(
66
        {   source => 'Item',
67
            value  => {
68
                itemlost  => 0,
69
                withdrawn => 0,
70
            },
71
        }
72
    );
73
    my $issue = $builder->build(
74
        {   source => 'Issue',
75
            value  => {
76
                borrowernumber => $patron->{borrowernumber},
77
                itemnumber     => $item->{itemnumber},
78
            },
79
        }
80
    );
81
82
    my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
83
    is( $returned, 1, 'The item should have been returned' );
84
    my ( $rows_affected, $err ) = C4::Circulation::AnonymiseIssueHistory('2010-10-11');
85
    ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' );
86
    is( $err, undef, 'AnonymiseIssueHistory should not return any error if success' );
87
88
    my $dbh = C4::Context->dbh;
89
    my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q|
90
        SELECT borrowernumber FROM old_issues where itemnumber = ?
91
    |, undef, $item->{itemnumber});
92
    is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'With privacy=1, the issue should have been anonymised' );
93
94
};
95
96
subtest 'patron privacy is 0 (forever)' => sub {
97
    plan tests => 3;
98
    t::lib::Mocks::mock_preference('IndependentBranches', 0);
99
100
    my $patron = $builder->build(
101
        {   source => 'Borrower',
102
            value  => { privacy => 0, branchcode => $userenv_patron->{branchcode} }
103
        }
104
    );
105
    my $item = $builder->build(
106
        {   source => 'Item',
107
            value  => {
108
                itemlost  => 0,
109
                withdrawn => 0,
110
            },
111
        }
112
    );
113
    my $issue = $builder->build(
114
        {   source => 'Issue',
115
            value  => {
116
                borrowernumber => $patron->{borrowernumber},
117
                itemnumber     => $item->{itemnumber},
118
            },
119
        }
120
    );
121
122
    my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
123
    is( $returned, 1, 'The item should have been returned' );
124
    my ( $rows_affected, $err ) = C4::Circulation::AnonymiseIssueHistory('2010-10-11');
125
    is( $err, undef, 'AnonymiseIssueHistory should not return any error if success' );
126
127
    my $dbh = C4::Context->dbh;
128
    my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q|
129
        SELECT borrowernumber FROM old_issues where itemnumber = ?
130
    |, undef, $item->{itemnumber});
131
    is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'With privacy=0, the issue should not be anonymised' );
132
};
133
134
t::lib::Mocks::mock_preference( 'AnonymousPatron', '' );
135
136
subtest 'AnonymousPatron is not defined' => sub {
137
    plan tests => 4;
138
    t::lib::Mocks::mock_preference('IndependentBranches', 0);
139
    my $patron = $builder->build(
140
        {   source => 'Borrower',
141
            value  => { privacy => 1, branchcode => $userenv_patron->{branchcode} }
142
        }
143
    );
144
    my $item = $builder->build(
145
        {   source => 'Item',
146
            value  => {
147
                itemlost  => 0,
148
                withdrawn => 0,
149
            },
150
        }
151
    );
152
    my $issue = $builder->build(
153
        {   source => 'Issue',
154
            value  => {
155
                borrowernumber => $patron->{borrowernumber},
156
                itemnumber     => $item->{itemnumber},
157
            },
158
        }
159
    );
160
161
    my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
162
    is( $returned, 1, 'The item should have been returned' );
163
    my ( $rows_affected, $err ) = C4::Circulation::AnonymiseIssueHistory('2010-10-11');
164
    ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' );
165
    is( $err, undef, 'AnonymiseIssueHistory should not return any error if success' );
166
167
    my $dbh = C4::Context->dbh;
168
    my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q|
169
        SELECT borrowernumber FROM old_issues where itemnumber = ?
170
    |, undef, $item->{itemnumber});
171
    is( $borrowernumber_used_to_anonymised, undef, 'With AnonymousPatron is not defined, the issue should have been anonymised anyway' );
172
};
173
174
subtest 'Logged in librarian is not superlibrarian & IndependentBranches' => sub {
175
    plan tests => 1;
176
    t::lib::Mocks::mock_preference('IndependentBranches', 1);
177
    my $patron = $builder->build(
178
        {   source => 'Borrower',
179
            value  => { privacy => 1 } # Another branchcode than the logged in librarian
180
        }
181
    );
182
    my $item = $builder->build(
183
        {   source => 'Item',
184
            value  => {
185
                itemlost  => 0,
186
                withdrawn => 0,
187
            },
188
        }
189
    );
190
    my $issue = $builder->build(
191
        {   source => 'Issue',
192
            value  => {
193
                borrowernumber => $patron->{borrowernumber},
194
                itemnumber     => $item->{itemnumber},
195
            },
196
        }
197
    );
198
199
    my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
200
    my $patrons_to_anonymise = C4::Members::GetBorrowersWithIssuesHistoryOlderThan( '2010-10-11' );
201
    my ( $rows_affected, $err ) = C4::Circulation::AnonymiseIssueHistory('2010-10-11');
202
    is( scalar(@$patrons_to_anonymise), $rows_affected, , 'AnonymiseIssueHistory should affect at least 1 row' );
203
};
204
205
subtest 'Test StoreLastBorrower' => sub {
206
    plan tests => 6;
207
208
    t::lib::Mocks::mock_preference( 'StoreLastBorrower', '1' );
209
210
    my $patron = $builder->build(
211
        {
212
            source => 'Borrower',
213
            value  => { privacy => 1, }
214
        }
215
    );
216
217
    my $item = $builder->build(
218
        {
219
            source => 'Item',
220
            value  => {
221
                itemlost  => 0,
222
                withdrawn => 0,
223
            },
224
        }
225
    );
226
227
    my $issue = $builder->build(
228
        {
229
            source => 'Issue',
230
            value  => {
231
                borrowernumber => $patron->{borrowernumber},
232
                itemnumber     => $item->{itemnumber},
233
            },
234
        }
235
    );
236
237
    my $item_object   = Koha::Items->find( $item->{itemnumber} );
238
    my $patron_object = $item_object->last_returned_by();
239
    is( $patron_object, undef, 'Koha::Item::last_returned_by returned undef' );
240
241
    my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
242
243
    $item_object   = Koha::Items->find( $item->{itemnumber} );
244
    $patron_object = $item_object->last_returned_by();
245
    is( ref($patron_object), 'Koha::Patron', 'Koha::Item::last_returned_by returned Koha::Patron' );
246
247
    $patron = $builder->build(
248
        {
249
            source => 'Borrower',
250
            value  => { privacy => 1, }
251
        }
252
    );
253
254
    $issue = $builder->build(
255
        {
256
            source => 'Issue',
257
            value  => {
258
                borrowernumber => $patron->{borrowernumber},
259
                itemnumber     => $item->{itemnumber},
260
            },
261
        }
262
    );
263
264
    ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
265
266
    $item_object   = Koha::Items->find( $item->{itemnumber} );
267
    $patron_object = $item_object->last_returned_by();
268
    is( $patron_object->id, $patron->{borrowernumber}, 'Second patron to return item replaces the first' );
269
270
    $patron = $builder->build(
271
        {
272
            source => 'Borrower',
273
            value  => { privacy => 1, }
274
        }
275
    );
276
    $patron_object = Koha::Patrons->find( $patron->{borrowernumber} );
277
278
    $item_object->last_returned_by($patron_object);
279
    $item_object = Koha::Items->find( $item->{itemnumber} );
280
    my $patron_object2 = $item_object->last_returned_by();
281
    is( $patron_object->id, $patron_object2->id,
282
        'Calling last_returned_by with Borrower object sets last_returned_by to that borrower' );
283
284
    $patron_object->delete;
285
    $item_object = Koha::Items->find( $item->{itemnumber} );
286
    is( $item_object->last_returned_by, undef, 'last_returned_by should return undef if the last patron to return the item has been deleted' );
287
288
    t::lib::Mocks::mock_preference( 'StoreLastBorrower', '0' );
289
    $patron = $builder->build(
290
        {
291
            source => 'Borrower',
292
            value  => { privacy => 1, }
293
        }
294
    );
295
296
    $issue = $builder->build(
297
        {
298
            source => 'Issue',
299
            value  => {
300
                borrowernumber => $patron->{borrowernumber},
301
                itemnumber     => $item->{itemnumber},
302
            },
303
        }
304
    );
305
    ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
306
307
    $item_object   = Koha::Items->find( $item->{itemnumber} );
308
    is( $item_object->last_returned_by, undef, 'Last patron to return item should not be stored if StoreLastBorrower if off' );
309
};
310
311
$schema->storage->txn_rollback;
312
313
1;
(-)a/t/db_dependent/Circulation/StoreLastBorrower.t (+144 lines)
Line 0 Link Here
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 => 1;
21
22
use C4::Context;
23
use C4::Circulation;
24
25
use Koha::Database;
26
use Koha::Items;
27
28
use t::lib::Mocks;
29
use t::lib::TestBuilder;
30
31
my $schema  = Koha::Database->new->schema;
32
$schema->storage->txn_begin;
33
34
my $builder = t::lib::TestBuilder->new;
35
36
subtest 'Test StoreLastBorrower' => sub {
37
    plan tests => 6;
38
39
    t::lib::Mocks::mock_preference( 'StoreLastBorrower', '1' );
40
41
    my $patron = $builder->build(
42
        {
43
            source => 'Borrower',
44
            value  => { privacy => 1, }
45
        }
46
    );
47
48
    my $item = $builder->build(
49
        {
50
            source => 'Item',
51
            value  => {
52
                itemlost  => 0,
53
                withdrawn => 0,
54
            },
55
        }
56
    );
57
58
    my $issue = $builder->build(
59
        {
60
            source => 'Issue',
61
            value  => {
62
                borrowernumber => $patron->{borrowernumber},
63
                itemnumber     => $item->{itemnumber},
64
            },
65
        }
66
    );
67
68
    my $item_object   = Koha::Items->find( $item->{itemnumber} );
69
    my $patron_object = $item_object->last_returned_by();
70
    is( $patron_object, undef, 'Koha::Item::last_returned_by returned undef' );
71
72
    my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, undef, '2010-10-10' );
73
74
    $item_object   = Koha::Items->find( $item->{itemnumber} );
75
    $patron_object = $item_object->last_returned_by();
76
    is( ref($patron_object), 'Koha::Patron', 'Koha::Item::last_returned_by returned Koha::Patron' );
77
78
    $patron = $builder->build(
79
        {
80
            source => 'Borrower',
81
            value  => { privacy => 1, }
82
        }
83
    );
84
85
    $issue = $builder->build(
86
        {
87
            source => 'Issue',
88
            value  => {
89
                borrowernumber => $patron->{borrowernumber},
90
                itemnumber     => $item->{itemnumber},
91
            },
92
        }
93
    );
94
95
    ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, undef, '2010-10-10' );
96
97
    $item_object   = Koha::Items->find( $item->{itemnumber} );
98
    $patron_object = $item_object->last_returned_by();
99
    is( $patron_object->id, $patron->{borrowernumber}, 'Second patron to return item replaces the first' );
100
101
    $patron = $builder->build(
102
        {
103
            source => 'Borrower',
104
            value  => { privacy => 1, }
105
        }
106
    );
107
    $patron_object = Koha::Patrons->find( $patron->{borrowernumber} );
108
109
    $item_object->last_returned_by($patron_object);
110
    $item_object = Koha::Items->find( $item->{itemnumber} );
111
    my $patron_object2 = $item_object->last_returned_by();
112
    is( $patron_object->id, $patron_object2->id,
113
        'Calling last_returned_by with Borrower object sets last_returned_by to that borrower' );
114
115
    $patron_object->delete;
116
    $item_object = Koha::Items->find( $item->{itemnumber} );
117
    is( $item_object->last_returned_by, undef, 'last_returned_by should return undef if the last patron to return the item has been deleted' );
118
119
    t::lib::Mocks::mock_preference( 'StoreLastBorrower', '0' );
120
    $patron = $builder->build(
121
        {
122
            source => 'Borrower',
123
            value  => { privacy => 1, }
124
        }
125
    );
126
127
    $issue = $builder->build(
128
        {
129
            source => 'Issue',
130
            value  => {
131
                borrowernumber => $patron->{borrowernumber},
132
                itemnumber     => $item->{itemnumber},
133
            },
134
        }
135
    );
136
    ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, undef, '2010-10-10' );
137
138
    $item_object   = Koha::Items->find( $item->{itemnumber} );
139
    is( $item_object->last_returned_by, undef, 'Last patron to return item should not be stored if StoreLastBorrower if off' );
140
};
141
142
$schema->storage->txn_rollback;
143
144
1;
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +177 lines)
Lines 19-31 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 18;
22
use Test::More tests => 19;
23
use Test::Warn;
23
use Test::Warn;
24
use DateTime;
24
use DateTime;
25
25
26
use C4::Biblio;
26
use C4::Biblio;
27
use C4::Circulation;
27
use C4::Circulation;
28
use C4::Members;
28
use C4::Members;
29
use C4::Circulation;
29
30
30
use Koha::Holds;
31
use Koha::Holds;
31
use Koha::Patron;
32
use Koha::Patron;
Lines 513-518 subtest 'account' => sub { Link Here
513
    $patron->delete;
514
    $patron->delete;
514
};
515
};
515
516
517
subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub {
518
    plan tests => 4;
519
520
    # TODO create a subroutine in t::lib::Mocks
521
    my $branch = $builder->build({ source => 'Branch' });
522
    my $userenv_patron = $builder->build({
523
        source => 'Borrower',
524
        value  => { branchcode => $branch->{branchcode} },
525
    });
526
    C4::Context->_new_userenv('DUMMY SESSION');
527
    C4::Context->set_userenv(
528
        $userenv_patron->{borrowernumber},
529
        $userenv_patron->{userid},
530
        'usercnum', 'First name', 'Surname',
531
        $branch->{branchcode},
532
        $branch->{branchname},
533
        0,
534
    );
535
    my $anonymous = $builder->build( { source => 'Borrower', }, );
536
537
    t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->{borrowernumber} );
538
539
    subtest 'patron privacy is 1 (default)' => sub {
540
        plan tests => 3;
541
542
        t::lib::Mocks::mock_preference('IndependentBranches', 0);
543
        my $patron = $builder->build(
544
            {   source => 'Borrower',
545
                value  => { privacy => 1, }
546
            }
547
        );
548
        my $item = $builder->build(
549
            {   source => 'Item',
550
                value  => {
551
                    itemlost  => 0,
552
                    withdrawn => 0,
553
                },
554
            }
555
        );
556
        my $issue = $builder->build(
557
            {   source => 'Issue',
558
                value  => {
559
                    borrowernumber => $patron->{borrowernumber},
560
                    itemnumber     => $item->{itemnumber},
561
                },
562
            }
563
        );
564
565
        my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
566
        is( $returned, 1, 'The item should have been returned' );
567
        my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11');
568
        ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' );
569
570
        my $dbh = C4::Context->dbh;
571
        my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q|
572
            SELECT borrowernumber FROM old_issues where itemnumber = ?
573
        |, undef, $item->{itemnumber});
574
        is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'With privacy=1, the issue should have been anonymised' );
575
        Koha::Patrons->find( $patron->{borrowernumber})->delete;
576
    };
577
578
    subtest 'patron privacy is 0 (forever)' => sub {
579
        plan tests => 3;
580
581
        t::lib::Mocks::mock_preference('IndependentBranches', 0);
582
        my $patron = $builder->build(
583
            {   source => 'Borrower',
584
                value  => { privacy => 0, }
585
            }
586
        );
587
        my $item = $builder->build(
588
            {   source => 'Item',
589
                value  => {
590
                    itemlost  => 0,
591
                    withdrawn => 0,
592
                },
593
            }
594
        );
595
        my $issue = $builder->build(
596
            {   source => 'Issue',
597
                value  => {
598
                    borrowernumber => $patron->{borrowernumber},
599
                    itemnumber     => $item->{itemnumber},
600
                },
601
            }
602
        );
603
604
        my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
605
        is( $returned, 1, 'The item should have been returned' );
606
        my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11');
607
        ok( $rows_affected > 0, 'AnonymiseIssueHistory should not return any error if success' );
608
609
        my $dbh = C4::Context->dbh;
610
        my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q|
611
            SELECT borrowernumber FROM old_issues where itemnumber = ?
612
        |, undef, $item->{itemnumber});
613
        is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'With privacy=0, the issue should not be anonymised' );
614
        Koha::Patrons->find( $patron->{borrowernumber})->delete;
615
    };
616
617
    t::lib::Mocks::mock_preference( 'AnonymousPatron', '' );
618
619
    subtest 'AnonymousPatron is not defined' => sub {
620
        plan tests => 3;
621
622
        t::lib::Mocks::mock_preference('IndependentBranches', 0);
623
        my $patron = $builder->build(
624
            {   source => 'Borrower',
625
                value  => { privacy => 1, }
626
            }
627
        );
628
        my $item = $builder->build(
629
            {   source => 'Item',
630
                value  => {
631
                    itemlost  => 0,
632
                    withdrawn => 0,
633
                },
634
            }
635
        );
636
        my $issue = $builder->build(
637
            {   source => 'Issue',
638
                value  => {
639
                    borrowernumber => $patron->{borrowernumber},
640
                    itemnumber     => $item->{itemnumber},
641
                },
642
            }
643
        );
644
645
        my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
646
        is( $returned, 1, 'The item should have been returned' );
647
        my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11');
648
        ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' );
649
650
        my $dbh = C4::Context->dbh;
651
        my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q|
652
            SELECT borrowernumber FROM old_issues where itemnumber = ?
653
        |, undef, $item->{itemnumber});
654
        is( $borrowernumber_used_to_anonymised, undef, 'With AnonymousPatron is not defined, the issue should have been anonymised anyway' );
655
        Koha::Patrons->find( $patron->{borrowernumber})->delete;
656
    };
657
658
    subtest 'Logged in librarian is not superlibrarian & IndependentBranches' => sub {
659
        plan tests => 1;
660
        t::lib::Mocks::mock_preference( 'IndependentBranches', 1 );
661
        my $patron = $builder->build(
662
            {   source => 'Borrower',
663
                value  => { privacy => 1 }    # Another branchcode than the logged in librarian
664
            }
665
        );
666
        my $item = $builder->build(
667
            {   source => 'Item',
668
                value  => {
669
                    itemlost  => 0,
670
                    withdrawn => 0,
671
                },
672
            }
673
        );
674
        my $issue = $builder->build(
675
            {   source => 'Issue',
676
                value  => {
677
                    borrowernumber => $patron->{borrowernumber},
678
                    itemnumber     => $item->{itemnumber},
679
                },
680
            }
681
        );
682
683
        my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
684
        is( Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->count, 0 );
685
        Koha::Patrons->find( $patron->{borrowernumber})->delete;
686
    };
687
688
    Koha::Patrons->find( $anonymous->{borrowernumber})->delete;
689
    Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete;
690
};
691
516
$retrieved_patron_1->delete;
692
$retrieved_patron_1->delete;
517
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
693
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
518
694
519
- 

Return to bug 16966