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

(-)a/t/db_dependent/Koha/Items.t (-12 / +17 lines)
Lines 1345-1351 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1345
            biblionumber => $biblio->biblionumber,
1345
            biblionumber => $biblio->biblionumber,
1346
            itemlost     => -1,
1346
            itemlost     => -1,
1347
            itype        => $itype_1->itemtype,
1347
            itype        => $itype_1->itemtype,
1348
            withdrawn    => 1
1348
            withdrawn    => 1,
1349
            copynumber   => undef
1349
        }
1350
        }
1350
    );
1351
    );
1351
    my $item_2 = $builder->build_sample_item(
1352
    my $item_2 = $builder->build_sample_item(
Lines 1353-1359 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1353
            biblionumber => $biblio->biblionumber,
1354
            biblionumber => $biblio->biblionumber,
1354
            itemlost     => 0,
1355
            itemlost     => 0,
1355
            itype        => $itype_2->itemtype,
1356
            itype        => $itype_2->itemtype,
1356
            withdrawn    => 2
1357
            withdrawn    => 2,
1358
            copynumber   => undef
1357
        }
1359
        }
1358
    );
1360
    );
1359
    my $item_3 = $builder->build_sample_item(
1361
    my $item_3 = $builder->build_sample_item(
Lines 1361-1367 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1361
            biblionumber => $biblio->biblionumber,
1363
            biblionumber => $biblio->biblionumber,
1362
            itemlost     => 1,
1364
            itemlost     => 1,
1363
            itype        => $itype_1->itemtype,
1365
            itype        => $itype_1->itemtype,
1364
            withdrawn    => 3
1366
            withdrawn    => 3,
1367
            copynumber   => undef
1365
        }
1368
        }
1366
    );
1369
    );
1367
    my $item_4 = $builder->build_sample_item(
1370
    my $item_4 = $builder->build_sample_item(
Lines 1369-1375 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1369
            biblionumber => $biblio->biblionumber,
1372
            biblionumber => $biblio->biblionumber,
1370
            itemlost     => 0,
1373
            itemlost     => 0,
1371
            itype        => $itype_2->itemtype,
1374
            itype        => $itype_2->itemtype,
1372
            withdrawn    => 4
1375
            withdrawn    => 4,
1376
            copynumber   => undef
1373
        }
1377
        }
1374
    );
1378
    );
1375
    my $item_5 = $builder->build_sample_item(
1379
    my $item_5 = $builder->build_sample_item(
Lines 1377-1383 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1377
            biblionumber => $biblio->biblionumber,
1381
            biblionumber => $biblio->biblionumber,
1378
            itemlost     => 0,
1382
            itemlost     => 0,
1379
            itype        => $itype_1->itemtype,
1383
            itype        => $itype_1->itemtype,
1380
            withdrawn    => 5
1384
            withdrawn    => 5,
1385
            copynumber   => undef
1381
        }
1386
        }
1382
    );
1387
    );
1383
    my $item_6 = $builder->build_sample_item(
1388
    my $item_6 = $builder->build_sample_item(
Lines 1385-1391 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1385
            biblionumber => $biblio->biblionumber,
1390
            biblionumber => $biblio->biblionumber,
1386
            itemlost     => 2,
1391
            itemlost     => 2,
1387
            itype        => $itype_1->itemtype,
1392
            itype        => $itype_1->itemtype,
1388
            withdrawn    => 5
1393
            withdrawn    => 5,
1394
            copynumber   => undef
1389
        }
1395
        }
1390
    );
1396
    );
1391
1397
Lines 1403-1409 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1403
    is( $biblio->items->filter_by_visible_in_opac({ patron => $patron })->count,
1409
    is( $biblio->items->filter_by_visible_in_opac({ patron => $patron })->count,
1404
        6, 'No rules passed, hidelostitems unset, patron exception changes nothing' );
1410
        6, 'No rules passed, hidelostitems unset, patron exception changes nothing' );
1405
1411
1406
    $rules = {};
1412
    $rules = { copynumber => [ 2 ] };
1407
1413
1408
    t::lib::Mocks::mock_preference( 'hidelostitems', 1 );
1414
    t::lib::Mocks::mock_preference( 'hidelostitems', 1 );
1409
    is(
1415
    is(
Lines 1418-1424 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1418
        'No rules passed, hidelostitems set, patron exception changes nothing'
1424
        'No rules passed, hidelostitems set, patron exception changes nothing'
1419
    );
1425
    );
1420
1426
1421
    $rules = { withdrawn => [ 1, 2 ] };
1427
    $rules = { withdrawn => [ 1, 2 ], copynumber => [ 2 ] };
1422
    is(
1428
    is(
1423
        $biblio->items->filter_by_visible_in_opac->count,
1429
        $biblio->items->filter_by_visible_in_opac->count,
1424
        2,
1430
        2,
Lines 1431-1444 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1431
        'hidelostitems set, rules on withdrawn but patron override passed'
1437
        'hidelostitems set, rules on withdrawn but patron override passed'
1432
    );
1438
    );
1433
1439
1434
    $rules = { itype => [ $itype_1->itemtype ] };
1440
    $rules = { itype => [ $itype_1->itemtype ], copynumber => [ 2 ] };
1435
    is(
1441
    is(
1436
        $biblio->items->filter_by_visible_in_opac->count,
1442
        $biblio->items->filter_by_visible_in_opac->count,
1437
        2,
1443
        2,
1438
        'Rules on itype, hidelostitems set'
1444
        'Rules on itype, hidelostitems set'
1439
    );
1445
    );
1440
1446
1441
    $rules = { withdrawn => [ 1, 2 ], itype => [ $itype_1->itemtype ] };
1447
    $rules = { withdrawn => [ 1, 2 ], itype => [ $itype_1->itemtype ], copynumber => [ 2 ] };
1442
    is(
1448
    is(
1443
        $biblio->items->filter_by_visible_in_opac->count,
1449
        $biblio->items->filter_by_visible_in_opac->count,
1444
        1,
1450
        1,
Lines 1451-1457 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1451
        'The right item is returned'
1457
        'The right item is returned'
1452
    );
1458
    );
1453
1459
1454
    $rules = { withdrawn => [ 1, 2 ], itype => [ $itype_2->itemtype ] };
1460
    $rules = { withdrawn => [ 1, 2 ], itype => [ $itype_2->itemtype ], copynumber => [ 2 ] };
1455
    is(
1461
    is(
1456
        $biblio->items->filter_by_visible_in_opac->count,
1462
        $biblio->items->filter_by_visible_in_opac->count,
1457
        1,
1463
        1,
1458
- 

Return to bug 27580