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

(-)a/Koha/Patrons.pm (+359 lines)
Lines 62-67 sub search_limited { Link Here
62
    return $self->search( $params, $attributes );
62
    return $self->search( $params, $attributes );
63
}
63
}
64
64
65
=head3 filter_by_is_guarantor
66
67
    Koha::Patrons->filter_by_is_guarantor(1);
68
69
Returns patrons filtered by whether they have a guarantor, are a guarantor or are not a guarantor.
70
71
=head4 options
72
73
=over 4
74
75
=item undef - do not apply filter
76
77
=item 1 - boolean to limit to NOT guarantors
78
79
=item 0 - boolean limit to ONLY guarantors
80
81
=back
82
83
=cut
84
85
sub filter_by_is_guarantor {
86
    my ( $self, $option ) = @_;
87
88
    return $self unless defined($option);
89
90
    my $guarantorList = Koha::Patrons->search(
91
        { guarantorid => [ { '!=' => 0 }, { '!=' => undef } ] },
92
        { select      => ['guarantorid'] } )->_resultset->as_query;
93
94
    # Patrons who are guarantors
95
    return $self->search(
96
        { 'me.borrowernumber' => { '-in' => $guarantorList } } )
97
      if $option;
98
99
    # Patrons who are not guarantors
100
    return $self->search(
101
        { 'me.borrowernumber' => { '-not_in' => $guarantorList } } );
102
}
103
104
=head3 filter_by_has_guarantor
105
106
    Koha::Patrons->filter_by_has_guarantor(1);
107
108
Returns patrons filtered by whether they have a guarantor, are a guarantor or are not a guarantor.
109
110
=head4 options
111
112
=over 4
113
114
=item undef - do not apply filter
115
116
=item 1 - boolean to limit to users who have a guarantor
117
118
=item 0 - boolean to limit to users who do not have a guarantor
119
120
=back
121
122
=cut
123
124
sub filter_by_has_guarantor {
125
    my ( $self, $option ) = @_;
126
127
    return $self unless defined($option);
128
129
    # Patrons who have guarantors
130
    return $self->search(
131
        { 'me.guarantorid' => [ { '!=' => 0 }, { '!=' => undef } ] } )
132
      if $option;
133
134
    # Patrons who do not have guarantors
135
    return $self->search( { 'me.guarantorid' => [ 0, undef ] } );
136
}
137
138
=head3 filter_by_last_issued
139
140
    Koha::Patrons->filter_by_last_issued( { after => DateTime, before => DateTime } );
141
142
Returns patrons filtered by whether their last issue falls betwen the passed limits.
143
144
=head4 arguments hashref
145
146
=over 4
147
148
=item before (optional) - filter out patrons whose last_issue was since DateTime
149
150
=item after (optional) - filter out patrons whose last_issue has been since DateTime
151
152
=back
153
154
=cut
155
156
sub filter_by_last_issued {
157
    my ( $self, $options ) = @_;
158
159
    return $self
160
      unless ( defined($options)
161
        && ( $options->{before} || $options->{after} ) );
162
163
    my $where = {};
164
    my $attrs = {
165
        join     => 'old_issues',
166
        group_by => 'me.borrowernumber',
167
        order_by => { '-desc' => 'old_issues.timestamp' }
168
    };
169
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
170
171
    push @{ $where->{'-and'} },
172
      { 'old_issues.timestamp' =>
173
          { '<' => $dtf->format_datetime( $options->{before} ) } }
174
      if $options->{before};
175
    push @{ $where->{'-and'} },
176
      { 'old_issues.timestamp' =>
177
          { '>' => $dtf->format_datetime( $options->{after} ) } }
178
      if $options->{after};
179
180
    return $self->search( $where, $attrs );
181
}
182
183
#sub filter_by_last_issued {
184
#    my ( $self, $options ) = @_;
185
#
186
#    return $self
187
#      unless ( defined($options)
188
#        && ( $options->{before} || $options->{after} ) );
189
#
190
#    my $where = {};
191
#    my $attrs = {
192
#        join      => 'old_issues',
193
#        group_by  => 'me.borrowernumber',
194
#        '+select' => [ { max => 'old_issues.timestamp', '-as' => 'last_issued' } ],
195
#        '+as'     => [ 'last_issued' ]
196
#    };
197
#    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
198
#
199
#    push @{ $attrs->{'having'}->{'-and'} },
200
#      { 'last_issued' => { '<' => $dtf->format_datetime( $options->{before} ) }
201
#      }
202
#      if $options->{before};
203
#
204
#    push @{ $attrs->{'having'}->{'-and'} },
205
#      { 'last_issued' => { '>' => $dtf->format_datetime( $options->{after} ) } }
206
#      if $options->{after};
207
#
208
#    return $self->search( $where, $attrs );
209
#}
210
211
=head3 filter_by_has_issues
212
213
    Koha::Patrons->filter_by_has_issues(1);
214
215
Returns patrons filtered by whether they have current issues or not.
216
217
=head4 options
218
219
=over 4
220
221
=item undef - do not apply filter
222
223
=item 0 - limit to patrons WITHOUT current issues
224
225
=item 1 - limit to patrons WITH current issues
226
227
=back
228
229
=cut
230
231
sub filter_by_has_issues {
232
    my ( $self, $option ) = @_;
233
234
    return $self
235
      unless defined($option);
236
237
    my $where = {};
238
    my $attrs = {
239
        join      => 'issues',
240
        group_by  => 'me.borrowernumber',
241
        '+select' => [ { count => 'issues.issue_id', -as => 'current_issues' } ],
242
        '+as'     => 'current_issues'
243
    };
244
245
    # Patrons who have current issues
246
    if ($option) {
247
        $attrs->{'having'} = { 'current_issues' => { '>' => 0 } };
248
    }
249
250
    # Patrons who do not have current issues
251
    else {
252
        $attrs->{'having'} = { 'current_issues' => 0 };
253
    }
254
255
    return $self->search($where,$attrs);
256
}
257
258
259
=head3 filter_by_when_expired
260
261
    Koha::Patrons->filter_by_when_expired( { after => DateTime, before => DateTime );
262
263
Returns patrons filtered by whether their accounts expired between between the passed limits.
264
265
=head4 arguments hashref
266
267
=over 4
268
269
=item before (optional) - filter out patrons whose expired_date was since DateTime
270
271
=item after (optional) - filter out patrons whose expired_date has been since DateTime
272
273
=back
274
275
=cut
276
277
sub filter_by_when_expired {
278
    my ( $self, $options ) = @_;
279
280
    return $self
281
      unless ( defined($options)
282
        && ( $options->{before} || $options->{after} ) );
283
284
    my $where = {};
285
    my $attrs = {};
286
    my $dtf   = Koha::Database->new->schema->storage->datetime_parser;
287
288
    # Before only
289
    $where->{'me.dateexpiry'} =
290
      { '<' => $dtf->format_datetime( $options->{before} ) }
291
      if ( $options->{before} && !$options->{after} );
292
293
    # After only (includes null)
294
    $where->{'me.dateexpiry'} =
295
      [ undef, { '>' => $dtf->format_datetime( $options->{after} ) } ]
296
      if ( !$options->{before} && $options->{after} );
297
298
    # Before and After (between)
299
    $where->{'me.dateexpiry'} = [
300
        '-and',
301
        { '<' => $dtf->format_datetime( $options->{before} ) },
302
        { '>' => $dtf->format_datetime( $options->{after} ) }
303
      ]
304
      if ( $options->{before} && $options->{after} );
305
306
    return $self->search( $where, $attrs );
307
}
308
309
310
=head3 filter_by_amount_owed
311
312
    Koha::Patrons->filter_by_amount_owed( { less_than => '2.00', more_than => '0.50' } );
313
314
Returns patrons filtered by how much money they owe, between passed limits.
315
316
=head4 arguments hashref
317
318
=over 4
319
320
=item less_than (optional) - filter out patrons who owe less than Amount
321
322
=item more_than (optional) - filter out patrons who owe more than Amount
323
324
=back
325
326
=cut
327
328
sub filter_by_amount_owed {
329
    my ( $self, $options ) = @_;
330
331
    return $self
332
      unless ( defined($options)
333
        && ( $options->{less_than} || $options->{more_than} ) );
334
335
    my $where = {};
336
    my $attrs = {
337
        join     => 'accountlines',
338
        group_by => 'me.borrowernumber',
339
        '+select' =>
340
          { sum => 'accountlines.amountoutstanding', '-as' => 'outstanding' },
341
        '+as' => 'outstanding'
342
    };
343
344
    $attrs->{'having'} = [
345
        { 'outstanding' => { '<' => $options->{less_than} } },
346
        { 'outstanding' => undef }
347
      ]
348
      if ( defined( $options->{less_than} )
349
        && !defined( $options->{more_than} ) );
350
351
    $attrs->{'having'} = { 'outstanding' => { '>' => $options->{more_than} } }
352
      if (!defined( $options->{less_than} )
353
        && defined( $options->{more_than} ) );
354
355
    $attrs->{'having'}->{'-and'} = [
356
        { 'outstanding' => { '>' => $options->{more_than} } },
357
        { 'outstanding' => { '<' => $options->{less_than} } }
358
      ]
359
      if ( defined( $options->{less_than} )
360
        && defined( $options->{more_than} ) );
361
362
    return $self->search( $where, $attrs );
363
}
364
365
366
=head3 filter_by_in_lists
367
368
    Koha::Patrons->filter_by_in_lists(\@lists);
369
370
Returns patrons filtered by whether that appear in ANY of the lists specified.
371
372
=head4 arguments arrayref
373
374
Arrayref of list ids
375
376
=back
377
378
=cut
379
380
sub filter_by_in_lists {
381
    my ( $self, $lists ) = @_;
382
383
    return $self
384
      unless defined($lists);
385
386
    my $where = {};
387
    my $attrs = { join => 'patron_list_patrons' };
388
389
    push @{ $where->{'-and'} },
390
      { 'patron_list_patrons.patron_list_id' => { '-in' => $lists } };
391
392
    return $self->search( $where, $attrs );
393
}
394
395
=head3 filter_by_not_in_lists
396
397
    Koha::Patrons->filter_by_not_in_lists(\@lists);
398
399
Returns patrons filtered by whether they do not appear in ANY of the lists specified.
400
401
=head4 arguments arrayref
402
403
Arrayref of list ids
404
405
=back
406
407
=cut
408
409
sub filter_by_not_in_lists {
410
    my ( $self, $lists ) = @_;
411
412
    return $self
413
      unless defined($lists);
414
415
    my $where = {};
416
    my $attrs = { join => 'patron_list_patrons' };
417
418
    push @{ $where->{'-and'} },
419
      { 'patron_list_patrons.patron_list_id' => { '-not_in' => $lists } };
420
421
    return $self->search( $where, $attrs );
422
}
423
65
=head3 search_housebound_choosers
424
=head3 search_housebound_choosers
66
425
67
Returns all Patrons which are Housebound choosers.
426
Returns all Patrons which are Housebound choosers.
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +337 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 31;
22
use Test::More tests => 32;
23
use Test::Warn;
23
use Test::Warn;
24
use Time::Fake;
24
use Time::Fake;
25
use DateTime;
25
use DateTime;
Lines 1377-1382 subtest 'Log cardnumber change' => sub { Link Here
1377
    is( scalar @logs, 2, 'With BorrowerLogs, Change in cardnumber should be logged, as well as general alert of patron mod.' );
1377
    is( scalar @logs, 2, 'With BorrowerLogs, Change in cardnumber should be logged, as well as general alert of patron mod.' );
1378
};
1378
};
1379
1379
1380
subtest 'complex filters' => sub {
1381
    plan tests => 7;
1382
1383
    my $now             = DateTime->now;
1384
    my $new_patron_cf_1 = Koha::Patron->new(
1385
        {
1386
            cardnumber   => 'test_cn_cf_1',
1387
            branchcode   => $library->{branchcode},
1388
            categorycode => $category->{categorycode},
1389
            surname      => 'surname for patron1',
1390
            firstname    => 'firstname for patron1',
1391
            userid       => 'a_nonexistent_userid_cf_1',
1392
            dateexpiry   => $now->clone->subtract( days => 14 )
1393
        }
1394
    )->store;
1395
    my $new_patron_cf_2 = Koha::Patron->new(
1396
        {
1397
            cardnumber   => 'test_cn_cf_2',
1398
            branchcode   => $library->{branchcode},
1399
            categorycode => $category->{categorycode},
1400
            surname      => 'surname for patron2',
1401
            firstname    => 'firstname for patron2',
1402
            userid       => 'a_nonexistent_userid_cf_2',
1403
            dateexpiry   => $now->clone->subtract( days => 7 )
1404
        }
1405
    )->store;
1406
    my $new_patron_cf_3 = Koha::Patron->new(
1407
        {
1408
            cardnumber   => 'test_cn_cf_3',
1409
            branchcode   => $library->{branchcode},
1410
            categorycode => $category->{categorycode},
1411
            surname      => 'surname for patron3',
1412
            firstname    => 'firstname for patron3',
1413
            userid       => 'a_nonexistent_userid_cf_3',
1414
        }
1415
    )->store;
1416
1417
    my $results = Koha::Patrons->search(
1418
        {
1419
            'me.borrowernumber' => [
1420
                $new_patron_cf_1->borrowernumber,
1421
                $new_patron_cf_2->borrowernumber,
1422
                $new_patron_cf_3->borrowernumber
1423
            ]
1424
        }
1425
    );
1426
1427
    subtest 'filter_by_is_guarantor' => sub {
1428
        plan tests => 6;
1429
1430
        # Set new_patron_cf_1 to be the guarantor for new_patron_cf_2
1431
        $new_patron_cf_2->guarantorid( $new_patron_cf_1->borrowernumber )
1432
          ->store;
1433
1434
        my $filtered = $results->filter_by_is_guarantor();
1435
        is( ref($filtered), 'Koha::Patrons',
1436
'Koha::Patrons->filter_by_is_guarantor should return a Koha::Patrons result set in a scalar context'
1437
        );
1438
        is( $filtered->count, 3,
1439
            'filter_by_is_guarantor() found both patrons' );
1440
1441
        $filtered = $results->filter_by_is_guarantor(1);
1442
        is( $filtered->count, 1, 'filter_by_is_guarantor(1) found one patron' );
1443
        is( $filtered->next->guarantees->count,
1444
            1, 'filter_by_is_guarantor(1) found the correct patron' );
1445
1446
        $filtered = $results->filter_by_is_guarantor(0);
1447
        is( $filtered->count, 2,
1448
            'filter_by_is_guarantor(0) found two patrons' );
1449
        is( $filtered->next->guarantees->count,
1450
            0, 'filter_by_is_guarantor(0) found the correct patrons' );
1451
    };
1452
1453
    subtest 'filter_by_has_guarantor' => sub {
1454
        plan tests => 6;
1455
1456
        my $filtered = $results->filter_by_has_guarantor();
1457
        is( ref($filtered), 'Koha::Patrons',
1458
'filter_by_has_guarantor() should return a Koha::Patrons result set in a scalar context'
1459
        );
1460
        is( $filtered->count, 3,
1461
            'filter_by_has_guarantor() found both patrons' );
1462
1463
        $filtered = $results->filter_by_has_guarantor(1);
1464
        is( $filtered->count, 1,
1465
            'filter_by_has_guarantor(1) found one patron' );
1466
        is(
1467
            $filtered->next->guarantorid,
1468
            $new_patron_cf_1->borrowernumber,
1469
            'filter_by_has_guarantor(1) found the correct patron'
1470
        );
1471
1472
        $filtered = $results->filter_by_has_guarantor(0);
1473
        is( $filtered->count, 2,
1474
            'filter_by_has_guarantor(0) found two patrons' );
1475
        is( $filtered->next->guarantorid,
1476
            undef, 'filter_by_has_guarantor(0) found the correct patrons' );
1477
    };
1478
1479
    subtest 'filter_by_last_issued' => sub {
1480
        plan tests => 4;
1481
1482
        my $first = DateTime->now()->subtract( days => 5 );
1483
        my $last = $first->clone->add( days => 2 );
1484
        my $old_issue_1 = $builder->build(
1485
            {
1486
                source => 'OldIssue',
1487
                value  => {
1488
                    borrowernumber => $new_patron_cf_1->borrowernumber,
1489
                    timestamp      => $first->clone->subtract( days => 1 )
1490
                },
1491
            }
1492
        );
1493
        my $old_issue_2 = $builder->build(
1494
            {
1495
                source => 'OldIssue',
1496
                value  => {
1497
                    borrowernumber => $new_patron_cf_2->borrowernumber,
1498
                    timestamp      => $last->clone->add( days => 1 )
1499
                },
1500
            }
1501
        );
1502
        my $old_issue_3 = $builder->build(
1503
            {
1504
                source => 'OldIssue',
1505
                value  => {
1506
                    borrowernumber => $new_patron_cf_3->borrowernumber,
1507
                    timestamp      => $first->clone->add( days => 1 )
1508
                },
1509
            }
1510
        );
1511
1512
        my $filtered = $results->filter_by_last_issued();
1513
        is( ref($filtered), 'Koha::Patrons',
1514
'filter_by_last_issued() should return a Koha::Patrons result set in a scalar context'
1515
        );
1516
1517
        $filtered = $results->filter_by_last_issued( { before => $last } );
1518
        is( $filtered->_resultset->as_subselect_rs->count,
1519
            2, "filter_by_last_issued({ before => $last }) found two patrons" );
1520
1521
        $filtered = $results->filter_by_last_issued( { after => $first } );
1522
        is( $filtered->_resultset->as_subselect_rs->count,
1523
            2, "filter_by_last_issued({ after => $first }) found two patrons" );
1524
1525
        $filtered = $results->filter_by_last_issued(
1526
            { after => $first, before => $last } );
1527
        is( $filtered->_resultset->as_subselect_rs->count, 1,
1528
"filter_by_last_issued({ after => $first, before => $last }) found two patrons"
1529
        );
1530
    };
1531
1532
    subtest 'filter_by_has_issues' => sub {
1533
        plan tests => 3;
1534
1535
        my $issue_1 = $builder->build(
1536
            {
1537
                source => 'Issue',
1538
                value  => {
1539
                    borrowernumber => $new_patron_cf_1->borrowernumber
1540
                },
1541
            }
1542
        );
1543
1544
        my $filtered = $results->filter_by_has_issues();
1545
        is( ref($filtered), 'Koha::Patrons',
1546
'filter_by_has_issues() should return a Koha::Patrons result set in a scalar context'
1547
        );
1548
1549
        $filtered = $results->filter_by_has_issues(1);
1550
        is( $filtered->_resultset->as_subselect_rs->count,
1551
            1, "filter_by_has_issues(1) found one patron" );
1552
1553
        $filtered = $results->filter_by_has_issues(0);
1554
        is( $filtered->_resultset->as_subselect_rs->count,
1555
            2, "filter_by_has_issues(0) found two patrons" );
1556
    };
1557
1558
    subtest 'filter_by_when_expired' => sub {
1559
        plan tests => 4;
1560
1561
        my $first  = $now->clone->subtract( days => 12 );
1562
        my $second = $now->clone->subtract( days => 4 );
1563
1564
        my $filtered = $results->filter_by_when_expired();
1565
        is( ref($filtered), 'Koha::Patrons',
1566
'Koha::Patrons->filter_by_when_expired should return a Koha::Patrons result set in a scalar context'
1567
        );
1568
1569
        $filtered = $results->filter_by_when_expired( { before => $second } );
1570
        is( $filtered->_resultset->as_subselect_rs->count,
1571
            2,
1572
            "filter_by_when_expired({ before => $second }) found two patrons" );
1573
1574
        $filtered = $results->filter_by_when_expired( { after => $first } );
1575
        is( $filtered->_resultset->as_subselect_rs->count,
1576
            2,
1577
            "filter_by_when_expired({ after => $first }) found two patrons" );
1578
1579
        $filtered = $results->filter_by_when_expired(
1580
            { after => $first, before => $second } );
1581
        is( $filtered->_resultset->as_subselect_rs->count, 1,
1582
"filter_by_when_expired({ after => $first, before => $second }) found one patrons"
1583
        );
1584
    };
1585
1586
    subtest 'filter_by_amount_owed' => sub {
1587
        plan tests => 4;
1588
1589
        my $fine1 = $builder->build(
1590
            {
1591
                source => 'Accountline',
1592
                value  => {
1593
                    borrowernumber    => $new_patron_cf_1->borrowernumber,
1594
                    amountoutstanding => 12.00
1595
                },
1596
            }
1597
        );
1598
        my $fine2 = $builder->build(
1599
            {
1600
                source => 'Accountline',
1601
                value  => {
1602
                    borrowernumber    => $new_patron_cf_2->borrowernumber,
1603
                    amountoutstanding => 8.00
1604
                },
1605
            }
1606
        );
1607
        my $fine3 = $builder->build(
1608
            {
1609
                source => 'Accountline',
1610
                value  => {
1611
                    borrowernumber    => $new_patron_cf_2->borrowernumber,
1612
                    amountoutstanding => 10.00
1613
                },
1614
            }
1615
        );
1616
1617
        my $filtered = $results->filter_by_amount_owed();
1618
        is( ref($filtered), 'Koha::Patrons',
1619
'Koha::Patrons->filter_by_amount_owed should return a Koha::Patrons result set in a scalar context'
1620
        );
1621
1622
        my $lower_limit = 12.00;
1623
        my $upper_limit = 16.00;
1624
1625
        # Catch user with 1 x 12.00 fine and user with no fines.
1626
        $filtered =
1627
          $results->filter_by_amount_owed( { less_than => $upper_limit } );
1628
        is( $filtered->_resultset->as_subselect_rs->count, 2,
1629
"filter_by_amount_owed({ less_than => $upper_limit }) found two patrons"
1630
        );
1631
1632
        # Catch user with 1 x 8.00 and 1 x 10.00 fine
1633
        $filtered =
1634
          $results->filter_by_amount_owed( { more_than => $lower_limit } );
1635
        is( $filtered->_resultset->as_subselect_rs->count, 1,
1636
"filter_by_amount_owed({ more_than => $lower_limit }) found two patrons"
1637
        );
1638
1639
        # User with 2 fines falls above upper limit, 
1640
        # user with 1 fine falls below lower limit 
1641
        # and user with no fines falls below lower limit.
1642
        $filtered = $results->filter_by_amount_owed(
1643
            { more_than => $lower_limit, less_than => $upper_limit } );
1644
        is( $filtered->_resultset->as_subselect_rs->count, 0,
1645
"filter_by_amount_owed({ more_than => $lower_limit, less_than => $upper_limit }) found one patrons"
1646
        );
1647
    };
1648
1649
    subtest 'filter_by_lists' => sub {
1650
        plan tests => 6;
1651
1652
        my $patronListPatron1 = $builder->build(
1653
            {
1654
                source => 'PatronListPatron',
1655
                value  => {
1656
                    borrowernumber => $new_patron_cf_1->borrowernumber
1657
                },
1658
            }
1659
        );
1660
        my $patronListPatron2 = $builder->build(
1661
            {
1662
                source => 'PatronListPatron',
1663
                value  => {
1664
                    borrowernumber => $new_patron_cf_2->borrowernumber
1665
                },
1666
            }
1667
        );
1668
        #my $patronListPatron3 = $builder->build(
1669
        #    {
1670
        #        source => 'PatronListPatron',
1671
        #        value  => {
1672
        #            borrowernumber => $new_patron_cf_2->borrowernumber,
1673
        #            patron_list_id => $patronListPatron1->patron_list_id
1674
        #        },
1675
        #    }
1676
        #);
1677
1678
        my $filtered = $results->filter_by_in_lists();
1679
        is( ref($filtered), 'Koha::Patrons',
1680
'Koha::Patrons->filter_by_in_lists should return a Koha::Patrons result set in a scalar context'
1681
        );
1682
1683
        $filtered = $results->filter_by_not_in_lists();
1684
        is( ref($filtered), 'Koha::Patrons',
1685
'Koha::Patrons->filter_by_not_in_lists should return a Koha::Patrons result set in a scalar context'
1686
        );
1687
1688
        $filtered =
1689
          $results->filter_by_in_lists(
1690
            [ $patronListPatron1->{patron_list_id} ] );
1691
        is( $filtered->_resultset->as_subselect_rs->count, 1,
1692
"filter_by_in_lists([$patronListPatron1->patron_list_id]) found one patron"
1693
        );
1694
        is( $filtered->next->borrowernumber, $new_patron_cf_1->borrowernumber,
1695
"filter_by_in_lists([$patronListPatron1->{patron_list_id}]) found the correct patron"
1696
        );
1697
        
1698
        $filtered =
1699
          $results->filter_by_in_lists(
1700
            [ $patronListPatron1->{patron_list_id} ] );
1701
        is( $filtered->_resultset->as_subselect_rs->count, 1,
1702
"filter_by_in_lists([$patronListPatron1->{patron_list_id}]) found one patron"
1703
        );
1704
        is( $filtered->next->borrowernumber, $new_patron_cf_1->borrowernumber,
1705
"filter_by_in_lists([$patronListPatron1->{patron_list_id}]) found the correct patron"
1706
        );
1707
1708
    };
1709
1710
    #    subtest 'chaining' => sub {
1711
    #    plan tests => 0;
1712
    #
1713
    #};
1714
};
1715
1380
$schema->storage->txn_rollback;
1716
$schema->storage->txn_rollback;
1381
1717
1382
subtest 'Test Koha::Patrons::merge' => sub {
1718
subtest 'Test Koha::Patrons::merge' => sub {
1383
- 

Return to bug 11983