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 (-1 / +176 lines)
Lines 23-28 use Test::More tests => 8; Link Here
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use C4::Circulation;
25
use C4::Circulation;
26
26
use Koha::Patron;
27
use Koha::Patron;
27
use Koha::Patrons;
28
use Koha::Patrons;
28
use Koha::Database;
29
use Koha::Database;
Lines 207-212 subtest 'renew_account' => sub { Link Here
207
    $retrieved_patron->delete;
208
    $retrieved_patron->delete;
208
};
209
};
209
210
211
subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub {
212
    plan tests => 4;
213
214
    # TODO create a subroutine in t::lib::Mocks
215
    my $branch = $builder->build({ source => 'Branch' });
216
    my $userenv_patron = $builder->build({
217
        source => 'Borrower',
218
        value  => { branchcode => $branch->{branchcode} },
219
    });
220
    C4::Context->_new_userenv('DUMMY SESSION');
221
    C4::Context->set_userenv(
222
        $userenv_patron->{borrowernumber},
223
        $userenv_patron->{userid},
224
        'usercnum', 'First name', 'Surname',
225
        $branch->{branchcode},
226
        $branch->{branchname},
227
        0,
228
    );
229
    my $anonymous = $builder->build( { source => 'Borrower', }, );
230
231
    t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->{borrowernumber} );
232
233
    subtest 'patron privacy is 1 (default)' => sub {
234
        plan tests => 3;
235
236
        t::lib::Mocks::mock_preference('IndependentBranches', 0);
237
        my $patron = $builder->build(
238
            {   source => 'Borrower',
239
                value  => { privacy => 1, }
240
            }
241
        );
242
        my $item = $builder->build(
243
            {   source => 'Item',
244
                value  => {
245
                    itemlost  => 0,
246
                    withdrawn => 0,
247
                },
248
            }
249
        );
250
        my $issue = $builder->build(
251
            {   source => 'Issue',
252
                value  => {
253
                    borrowernumber => $patron->{borrowernumber},
254
                    itemnumber     => $item->{itemnumber},
255
                },
256
            }
257
        );
258
259
        my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
260
        is( $returned, 1, 'The item should have been returned' );
261
        my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11');
262
        ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' );
263
264
        my $dbh = C4::Context->dbh;
265
        my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q|
266
            SELECT borrowernumber FROM old_issues where itemnumber = ?
267
        |, undef, $item->{itemnumber});
268
        is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'With privacy=1, the issue should have been anonymised' );
269
        Koha::Patrons->find( $patron->{borrowernumber})->delete;
270
    };
271
272
    subtest 'patron privacy is 0 (forever)' => sub {
273
        plan tests => 3;
274
275
        t::lib::Mocks::mock_preference('IndependentBranches', 0);
276
        my $patron = $builder->build(
277
            {   source => 'Borrower',
278
                value  => { privacy => 0, }
279
            }
280
        );
281
        my $item = $builder->build(
282
            {   source => 'Item',
283
                value  => {
284
                    itemlost  => 0,
285
                    withdrawn => 0,
286
                },
287
            }
288
        );
289
        my $issue = $builder->build(
290
            {   source => 'Issue',
291
                value  => {
292
                    borrowernumber => $patron->{borrowernumber},
293
                    itemnumber     => $item->{itemnumber},
294
                },
295
            }
296
        );
297
298
        my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
299
        is( $returned, 1, 'The item should have been returned' );
300
        my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11');
301
        ok( $rows_affected > 0, 'AnonymiseIssueHistory should not return any error if success' );
302
303
        my $dbh = C4::Context->dbh;
304
        my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q|
305
            SELECT borrowernumber FROM old_issues where itemnumber = ?
306
        |, undef, $item->{itemnumber});
307
        is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'With privacy=0, the issue should not be anonymised' );
308
        Koha::Patrons->find( $patron->{borrowernumber})->delete;
309
    };
310
311
    t::lib::Mocks::mock_preference( 'AnonymousPatron', '' );
312
313
    subtest 'AnonymousPatron is not defined' => sub {
314
        plan tests => 3;
315
316
        t::lib::Mocks::mock_preference('IndependentBranches', 0);
317
        my $patron = $builder->build(
318
            {   source => 'Borrower',
319
                value  => { privacy => 1, }
320
            }
321
        );
322
        my $item = $builder->build(
323
            {   source => 'Item',
324
                value  => {
325
                    itemlost  => 0,
326
                    withdrawn => 0,
327
                },
328
            }
329
        );
330
        my $issue = $builder->build(
331
            {   source => 'Issue',
332
                value  => {
333
                    borrowernumber => $patron->{borrowernumber},
334
                    itemnumber     => $item->{itemnumber},
335
                },
336
            }
337
        );
338
339
        my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
340
        is( $returned, 1, 'The item should have been returned' );
341
        my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11');
342
        ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' );
343
344
        my $dbh = C4::Context->dbh;
345
        my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q|
346
            SELECT borrowernumber FROM old_issues where itemnumber = ?
347
        |, undef, $item->{itemnumber});
348
        is( $borrowernumber_used_to_anonymised, undef, 'With AnonymousPatron is not defined, the issue should have been anonymised anyway' );
349
        Koha::Patrons->find( $patron->{borrowernumber})->delete;
350
    };
351
352
    subtest 'Logged in librarian is not superlibrarian & IndependentBranches' => sub {
353
        plan tests => 1;
354
        t::lib::Mocks::mock_preference( 'IndependentBranches', 1 );
355
        my $patron = $builder->build(
356
            {   source => 'Borrower',
357
                value  => { privacy => 1 }    # Another branchcode than the logged in librarian
358
            }
359
        );
360
        my $item = $builder->build(
361
            {   source => 'Item',
362
                value  => {
363
                    itemlost  => 0,
364
                    withdrawn => 0,
365
                },
366
            }
367
        );
368
        my $issue = $builder->build(
369
            {   source => 'Issue',
370
                value  => {
371
                    borrowernumber => $patron->{borrowernumber},
372
                    itemnumber     => $item->{itemnumber},
373
                },
374
            }
375
        );
376
377
        my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
378
        is( Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->count, 0 );
379
        Koha::Patrons->find( $patron->{borrowernumber})->delete;
380
    };
381
382
    Koha::Patrons->find( $anonymous->{borrowernumber})->delete;
383
    Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete;
384
};
385
210
$retrieved_patron_1->delete;
386
$retrieved_patron_1->delete;
211
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
387
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
212
388
213
- 

Return to bug 16966