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

(-)a/t/db_dependent/Amazon.t (-8 / +9 lines)
Lines 7-12 use strict; Link Here
7
use warnings;
7
use warnings;
8
8
9
use Test::More tests => 8;
9
use Test::More tests => 8;
10
use t::lib::Mocks;
10
use C4::Context;
11
use C4::Context;
11
12
12
BEGIN {
13
BEGIN {
Lines 17-49 my $context = C4::Context->new(); Link Here
17
18
18
my $locale = $context->preference('AmazonLocale');
19
my $locale = $context->preference('AmazonLocale');
19
20
20
$context->set_preference('AmazonLocale','CA');
21
$contextt::lib::Mocks::mock_preference('AmazonLocale','CA');
21
$context->clear_syspref_cache();
22
$context->clear_syspref_cache();
22
is(get_amazon_tld,'.ca','Changes locale to CA and tests get_amazon_tld');
23
is(get_amazon_tld,'.ca','Changes locale to CA and tests get_amazon_tld');
23
24
24
$context->set_preference('AmazonLocale','DE');
25
$contextt::lib::Mocks::mock_preference('AmazonLocale','DE');
25
$context->clear_syspref_cache();
26
$context->clear_syspref_cache();
26
is(get_amazon_tld,'.de','Changes locale to DE and tests get_amazon_tld');
27
is(get_amazon_tld,'.de','Changes locale to DE and tests get_amazon_tld');
27
28
28
$context->set_preference('AmazonLocale','FR');
29
$contextt::lib::Mocks::mock_preference('AmazonLocale','FR');
29
$context->clear_syspref_cache();
30
$context->clear_syspref_cache();
30
is(get_amazon_tld,'.fr','Changes locale to FR and tests get_amazon_tld');
31
is(get_amazon_tld,'.fr','Changes locale to FR and tests get_amazon_tld');
31
32
32
$context->set_preference('AmazonLocale','JP');
33
$contextt::lib::Mocks::mock_preference('AmazonLocale','JP');
33
$context->clear_syspref_cache();
34
$context->clear_syspref_cache();
34
is(get_amazon_tld,'.jp','Changes locale to JP and tests get_amazon_tld');
35
is(get_amazon_tld,'.jp','Changes locale to JP and tests get_amazon_tld');
35
36
36
$context->set_preference('AmazonLocale','UK');
37
$contextt::lib::Mocks::mock_preference('AmazonLocale','UK');
37
$context->clear_syspref_cache();
38
$context->clear_syspref_cache();
38
is(get_amazon_tld,'.co.uk','Changes locale to UK and tests get_amazon_tld');
39
is(get_amazon_tld,'.co.uk','Changes locale to UK and tests get_amazon_tld');
39
40
40
$context->set_preference('AmazonLocale','US');
41
$contextt::lib::Mocks::mock_preference('AmazonLocale','US');
41
$context->clear_syspref_cache();
42
$context->clear_syspref_cache();
42
is(get_amazon_tld,'.com','Changes locale to US and tests get_amazon_tld');
43
is(get_amazon_tld,'.com','Changes locale to US and tests get_amazon_tld');
43
44
44
$context->set_preference('AmazonLocale','NZ');
45
$contextt::lib::Mocks::mock_preference('AmazonLocale','NZ');
45
$context->clear_syspref_cache();
46
$context->clear_syspref_cache();
46
is(get_amazon_tld,'.com','Changes locale to one not in the array and tests get_amazon_tld');
47
is(get_amazon_tld,'.com','Changes locale to one not in the array and tests get_amazon_tld');
47
48
48
$context->set_preference('AmazonLocale',$locale);
49
$contextt::lib::Mocks::mock_preference('AmazonLocale',$locale);
49
$context->clear_syspref_cache();
50
$context->clear_syspref_cache();
(-)a/t/db_dependent/Auth.t (-3 / +4 lines)
Lines 10-15 use Test::MockModule; Link Here
10
use List::MoreUtils qw/all any none/;
10
use List::MoreUtils qw/all any none/;
11
use Test::More tests => 13;
11
use Test::More tests => 13;
12
use Test::Warn;
12
use Test::Warn;
13
use t::lib::Mocks;
13
use C4::Members;
14
use C4::Members;
14
use Koha::AuthUtils qw/hash_password/;
15
use Koha::AuthUtils qw/hash_password/;
15
16
Lines 61-70 $dbh->{RaiseError} = 1; Link Here
61
    $auth->mock( 'checkauth', \&MockedCheckauth );
62
    $auth->mock( 'checkauth', \&MockedCheckauth );
62
63
63
    # Make sure 'EnableOpacSearchHistory' is set
64
    # Make sure 'EnableOpacSearchHistory' is set
64
    C4::Context->set_preference('EnableOpacSearchHistory',1);
65
    t::lib::Mocks::mock_preference('EnableOpacSearchHistory',1);
65
    # Enable es-ES for the OPAC and staff interfaces
66
    # Enable es-ES for the OPAC and staff interfaces
66
    C4::Context->set_preference('opaclanguages','en,es-ES');
67
    t::lib::Mocks::mock_preference('opaclanguages','en,es-ES');
67
    C4::Context->set_preference('language','en,es-ES');
68
    t::lib::Mocks::mock_preference('language','en,es-ES');
68
69
69
    # we need a session cookie
70
    # we need a session cookie
70
    $ENV{"SERVER_PORT"} = 80;
71
    $ENV{"SERVER_PORT"} = 80;
(-)a/t/db_dependent/Auth_with_cas.t (-2 / +3 lines)
Lines 20-25 use Modern::Perl; Link Here
20
use Test::More tests => 4;
20
use Test::More tests => 4;
21
use CGI;
21
use CGI;
22
22
23
use t::lib::Mocks;
23
use C4::Context;
24
use C4::Context;
24
25
25
BEGIN {
26
BEGIN {
Lines 39-46 $dbh->{ AutoCommit } = 0; Link Here
39
$dbh->{ RaiseError } = 1;
40
$dbh->{ RaiseError } = 1;
40
41
41
C4::Context->disable_syspref_cache();
42
C4::Context->disable_syspref_cache();
42
C4::Context->set_preference('OPACBaseURL','http://localhost');
43
t::lib::Mocks::mock_preference('OPACBaseURL','http://localhost');
43
C4::Context->set_preference('staffClientBaseURL','localhost:8080');
44
t::lib::Mocks::mock_preference('staffClientBaseURL','localhost:8080');
44
45
45
my $opac_base_url = C4::Context->preference('OpacBaseURL');
46
my $opac_base_url = C4::Context->preference('OpacBaseURL');
46
my $staff_base_url = C4::Context->preference('staffClientBaseURL');
47
my $staff_base_url = C4::Context->preference('staffClientBaseURL');
(-)a/t/db_dependent/Bookseller.t (-2 / +3 lines)
Lines 9-14 use Test::Warn; Link Here
9
use C4::Context;
9
use C4::Context;
10
use Koha::DateUtils;
10
use Koha::DateUtils;
11
use DateTime::Duration;
11
use DateTime::Duration;
12
use t::lib::Mocks;
12
use C4::Acquisition;
13
use C4::Acquisition;
13
use C4::Serials;
14
use C4::Serials;
14
use C4::Budgets;
15
use C4::Budgets;
Lines 656-662 $module->mock( Link Here
656
    }
657
    }
657
);
658
);
658
659
659
C4::Context->set_preference('IndependentBranches', 0);
660
t::lib::Mocks::mock_preference('IndependentBranches', 0);
660
@subscriptions = SearchSubscriptions({expiration_date => '2013-12-31'});
661
@subscriptions = SearchSubscriptions({expiration_date => '2013-12-31'});
661
is(
662
is(
662
    scalar(grep { !$_->{cannotdisplay} } @subscriptions ),
663
    scalar(grep { !$_->{cannotdisplay} } @subscriptions ),
Lines 664-670 is( Link Here
664
    'ordinary user can see all subscriptions with IndependentBranches off'
665
    'ordinary user can see all subscriptions with IndependentBranches off'
665
);
666
);
666
667
667
C4::Context->set_preference('IndependentBranches', 1);
668
t::lib::Mocks::mock_preference('IndependentBranches', 1);
668
@subscriptions = SearchSubscriptions({expiration_date => '2013-12-31'});
669
@subscriptions = SearchSubscriptions({expiration_date => '2013-12-31'});
669
is(
670
is(
670
    scalar(grep { !$_->{cannotdisplay} } @subscriptions ),
671
    scalar(grep { !$_->{cannotdisplay} } @subscriptions ),
(-)a/t/db_dependent/Circulation.t (-22 / +23 lines)
Lines 18-23 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use DateTime;
20
use DateTime;
21
use t::lib::Mocks;
21
use C4::Biblio;
22
use C4::Biblio;
22
use C4::Branch;
23
use C4::Branch;
23
use C4::Items;
24
use C4::Items;
Lines 66-72 my $borrower = { Link Here
66
};
67
};
67
68
68
# No userenv, PickupLibrary
69
# No userenv, PickupLibrary
69
C4::Context->set_preference('CircControl', 'PickupLibrary');
70
t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary');
70
is(
71
is(
71
    C4::Context->preference('CircControl'),
72
    C4::Context->preference('CircControl'),
72
    'PickupLibrary',
73
    'PickupLibrary',
Lines 79-85 is( Link Here
79
);
80
);
80
81
81
# No userenv, PatronLibrary
82
# No userenv, PatronLibrary
82
C4::Context->set_preference('CircControl', 'PatronLibrary');
83
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary');
83
is(
84
is(
84
    C4::Context->preference('CircControl'),
85
    C4::Context->preference('CircControl'),
85
    'PatronLibrary',
86
    'PatronLibrary',
Lines 92-98 is( Link Here
92
);
93
);
93
94
94
# No userenv, ItemHomeLibrary
95
# No userenv, ItemHomeLibrary
95
C4::Context->set_preference('CircControl', 'ItemHomeLibrary');
96
t::lib::Mocks::mock_preference('CircControl', 'ItemHomeLibrary');
96
is(
97
is(
97
    C4::Context->preference('CircControl'),
98
    C4::Context->preference('CircControl'),
98
    'ItemHomeLibrary',
99
    'ItemHomeLibrary',
Lines 110-116 C4::Context->set_userenv(0,0,0,'firstname','surname', $library2->{branchcode}, ' Link Here
110
is(C4::Context->userenv->{branch}, $library2->{branchcode}, 'userenv set');
111
is(C4::Context->userenv->{branch}, $library2->{branchcode}, 'userenv set');
111
112
112
# Userenv set, PickupLibrary
113
# Userenv set, PickupLibrary
113
C4::Context->set_preference('CircControl', 'PickupLibrary');
114
t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary');
114
is(
115
is(
115
    C4::Context->preference('CircControl'),
116
    C4::Context->preference('CircControl'),
116
    'PickupLibrary',
117
    'PickupLibrary',
Lines 123-129 is( Link Here
123
);
124
);
124
125
125
# Userenv set, PatronLibrary
126
# Userenv set, PatronLibrary
126
C4::Context->set_preference('CircControl', 'PatronLibrary');
127
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary');
127
is(
128
is(
128
    C4::Context->preference('CircControl'),
129
    C4::Context->preference('CircControl'),
129
    'PatronLibrary',
130
    'PatronLibrary',
Lines 136-142 is( Link Here
136
);
137
);
137
138
138
# Userenv set, ItemHomeLibrary
139
# Userenv set, ItemHomeLibrary
139
C4::Context->set_preference('CircControl', 'ItemHomeLibrary');
140
t::lib::Mocks::mock_preference('CircControl', 'ItemHomeLibrary');
140
is(
141
is(
141
    C4::Context->preference('CircControl'),
142
    C4::Context->preference('CircControl'),
142
    'ItemHomeLibrary',
143
    'ItemHomeLibrary',
Lines 149-155 is( Link Here
149
);
150
);
150
151
151
# Reset initial configuration
152
# Reset initial configuration
152
C4::Context->set_preference('CircControl', $CircControl);
153
t::lib::Mocks::mock_preference('CircControl', $CircControl);
153
is(
154
is(
154
    C4::Context->preference('CircControl'),
155
    C4::Context->preference('CircControl'),
155
    $CircControl,
156
    $CircControl,
Lines 318-324 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
318
319
319
    # Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds
320
    # Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds
320
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1");
321
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1");
321
    C4::Context->set_preference('AllowRenewalIfOtherItemsAvailable', 1 );
322
    t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 );
322
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber);
323
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber);
323
    is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');
324
    is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');
324
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2);
325
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2);
Lines 354-360 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
354
    is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');
355
    is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');
355
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2);
356
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2);
356
    is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');
357
    is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');
357
    C4::Context->set_preference('AllowRenewalIfOtherItemsAvailable', 0 );
358
    t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 0 );
358
359
359
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber);
360
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber);
360
    is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved');
361
    is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved');
Lines 410-416 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
410
    my $datedue5 = AddIssue($restricted_borrower, $barcode5);
411
    my $datedue5 = AddIssue($restricted_borrower, $barcode5);
411
    is (defined $datedue5, 1, "Item with date due checked out, due date: $datedue5");
412
    is (defined $datedue5, 1, "Item with date due checked out, due date: $datedue5");
412
413
413
    C4::Context->set_preference('RestrictionBlockRenewing','1');
414
    t::lib::Mocks::mock_preference('RestrictionBlockRenewing','1');
414
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2);
415
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2);
415
    is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted');
416
    is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted');
416
    ( $renewokay, $error ) = CanBookBeRenewed($restricted_borrowernumber, $itemnumber5);
417
    ( $renewokay, $error ) = CanBookBeRenewed($restricted_borrowernumber, $itemnumber5);
Lines 445-451 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
445
    is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: $passeddatedue1");
446
    is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: $passeddatedue1");
446
447
447
448
448
    C4::Context->set_preference('OverduesBlockRenewing','blockitem');
449
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','blockitem');
449
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6);
450
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6);
450
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
451
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
451
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7);
452
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7);
Lines 486-492 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
486
487
487
    # Bug 14395
488
    # Bug 14395
488
    # Test 'exact time' setting for syspref NoRenewalBeforePrecision
489
    # Test 'exact time' setting for syspref NoRenewalBeforePrecision
489
    C4::Context->set_preference( 'NoRenewalBeforePrecision', 'exact_time' );
490
    t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'exact_time' );
490
    is(
491
    is(
491
        GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ),
492
        GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ),
492
        $datedue->clone->add( days => -7 ),
493
        $datedue->clone->add( days => -7 ),
Lines 495-501 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
495
496
496
    # Bug 14395
497
    # Bug 14395
497
    # Test 'date' setting for syspref NoRenewalBeforePrecision
498
    # Test 'date' setting for syspref NoRenewalBeforePrecision
498
    C4::Context->set_preference( 'NoRenewalBeforePrecision', 'date' );
499
    t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' );
499
    is(
500
    is(
500
        GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ),
501
        GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ),
501
        $datedue->clone->add( days => -7 )->truncate( to => 'day' ),
502
        $datedue->clone->add( days => -7 )->truncate( to => 'day' ),
Lines 541-548 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
541
    is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)');
542
    is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)');
542
543
543
    # Test WhenLostForgiveFine and WhenLostChargeReplacementFee
544
    # Test WhenLostForgiveFine and WhenLostChargeReplacementFee
544
    C4::Context->set_preference('WhenLostForgiveFine','1');
545
    t::lib::Mocks::mock_preference('WhenLostForgiveFine','1');
545
    C4::Context->set_preference('WhenLostChargeReplacementFee','1');
546
    t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','1');
546
547
547
    C4::Overdues::UpdateFine(
548
    C4::Overdues::UpdateFine(
548
        {
549
        {
Lines 569-576 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
569
570
570
    C4::Context->dbh->do("DELETE FROM accountlines");
571
    C4::Context->dbh->do("DELETE FROM accountlines");
571
572
572
    C4::Context->set_preference('WhenLostForgiveFine','0');
573
    t::lib::Mocks::mock_preference('WhenLostForgiveFine','0');
573
    C4::Context->set_preference('WhenLostChargeReplacementFee','0');
574
    t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','0');
574
575
575
    C4::Overdues::UpdateFine(
576
    C4::Overdues::UpdateFine(
576
        {
577
        {
Lines 602-608 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
602
    ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' );
603
    ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' );
603
604
604
    # Users cannot renew any item if there is an overdue item
605
    # Users cannot renew any item if there is an overdue item
605
    C4::Context->set_preference('OverduesBlockRenewing','block');
606
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','block');
606
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6);
607
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6);
607
    is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue');
608
    is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue');
608
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7);
609
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7);
Lines 807-828 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
807
    );
808
    );
808
809
809
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0");
810
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0");
810
    C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 0 );
811
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 );
811
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
812
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
812
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' );
813
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' );
813
814
814
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0");
815
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0");
815
    C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
816
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
816
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
817
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
817
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' );
818
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' );
818
819
819
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1");
820
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1");
820
    C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 0 );
821
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 );
821
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
822
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
822
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' );
823
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' );
823
824
824
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1");
825
    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1");
825
    C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
826
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
826
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
827
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
827
    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );
828
    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );
828
829
(-)a/t/db_dependent/Circulation/GetTopIssues.t (-1 / +2 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Test::More tests => 14;
20
use Test::More tests => 14;
21
use Test::MockModule;
21
use Test::MockModule;
22
use t::lib::Mocks;
22
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
23
24
24
use C4::Context;
25
use C4::Context;
Lines 46-52 my $c4_context = Test::MockModule->new('C4::Context'); Link Here
46
$c4_context->mock('userenv', sub {
47
$c4_context->mock('userenv', sub {
47
    { branch => $branch_1->{ branchcode } }
48
    { branch => $branch_1->{ branchcode } }
48
});
49
});
49
C4::Context->set_preference('item-level_itypes', '0');
50
t::lib::Mocks::mock_preference('item-level_itypes', '0');
50
51
51
my $biblionumber = create_biblio('Test 1', $itemtype);
52
my $biblionumber = create_biblio('Test 1', $itemtype);
52
AddItem({
53
AddItem({
(-)a/t/db_dependent/Circulation/Returns.t (-2 / +3 lines)
Lines 1-6 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
use Test::More tests => 2;
2
use Test::More tests => 2;
3
3
4
use t::lib::Mocks;
4
use C4::Biblio;
5
use C4::Biblio;
5
use C4::Circulation;
6
use C4::Circulation;
6
use C4::Items;
7
use C4::Items;
Lines 38-44 my ( undef, undef, $itemnumber ) = AddItem( Link Here
38
39
39
my $item;
40
my $item;
40
41
41
C4::Context->set_preference( "InProcessingToShelvingCart", 1 );
42
t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 1 );
42
AddReturn( 'i_dont_exist', $library->{branchcode} );
43
AddReturn( 'i_dont_exist', $library->{branchcode} );
43
$item = GetItem($itemnumber);
44
$item = GetItem($itemnumber);
44
is( $item->{location}, 'CART', "InProcessingToShelvingCart functions as intended" );
45
is( $item->{location}, 'CART', "InProcessingToShelvingCart functions as intended" );
Lines 46-52 is( $item->{location}, 'CART', "InProcessingToShelvingCart functions as intended Link Here
46
$item->{location} = 'PROC';
47
$item->{location} = 'PROC';
47
ModItem( $item, undef, $itemnumber );
48
ModItem( $item, undef, $itemnumber );
48
49
49
C4::Context->set_preference( "InProcessingToShelvingCart", 0 );
50
t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 0 );
50
AddReturn( 'i_dont_exist', $library->{branchcode} );
51
AddReturn( 'i_dont_exist', $library->{branchcode} );
51
$item = GetItem($itemnumber);
52
$item = GetItem($itemnumber);
52
is( $item->{location}, 'TEST', "InProcessingToShelvingCart functions as intended" );
53
is( $item->{location}, 'TEST', "InProcessingToShelvingCart functions as intended" );
(-)a/t/db_dependent/Circulation_Branch.t (-1 / +2 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use t::lib::Mocks;
4
use C4::Biblio;
5
use C4::Biblio;
5
use C4::Members;
6
use C4::Members;
6
use C4::Circulation;
7
use C4::Circulation;
Lines 315-321 is_deeply( Link Here
315
);
316
);
316
317
317
# Test return policies
318
# Test return policies
318
C4::Context->set_preference('AutomaticItemReturn','0');
319
t::lib::Mocks::mock_preference('AutomaticItemReturn','0');
319
320
320
# item1 returned at branch2 should trigger transfer to homebranch
321
# item1 returned at branch2 should trigger transfer to homebranch
321
$query =
322
$query =
(-)a/t/db_dependent/Circulation_issue.t (-2 / +3 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Koha::DateUtils;
20
use Koha::DateUtils;
21
use DateTime::Duration;
21
use DateTime::Duration;
22
use t::lib::Mocks;
22
use C4::Biblio;
23
use C4::Biblio;
23
use C4::Members;
24
use C4::Members;
24
use C4::Circulation;
25
use C4::Circulation;
Lines 373-384 my $itemnumber; Link Here
373
    $biblionumber
374
    $biblionumber
374
);
375
);
375
376
376
C4::Context->set_preference( 'UpdateNotForLoanStatusOnCheckin', q{} );
377
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} );
377
AddReturn( 'barcode_3', $samplebranch1->{branchcode} );
378
AddReturn( 'barcode_3', $samplebranch1->{branchcode} );
378
my $item = GetItem( $itemnumber );
379
my $item = GetItem( $itemnumber );
379
ok( $item->{notforloan} eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' );
380
ok( $item->{notforloan} eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' );
380
381
381
C4::Context->set_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' );
382
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' );
382
AddReturn( 'barcode_3', $samplebranch1->{branchcode} );
383
AddReturn( 'barcode_3', $samplebranch1->{branchcode} );
383
$item = GetItem( $itemnumber );
384
$item = GetItem( $itemnumber );
384
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9"} );
385
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9"} );
(-)a/t/db_dependent/Hold.t (-2 / +3 lines)
Lines 17-22 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use t::lib::Mocks;
20
use C4::Context;
21
use C4::Context;
21
use C4::Biblio qw( AddBiblio );
22
use C4::Biblio qw( AddBiblio );
22
use Koha::Database;
23
use Koha::Database;
Lines 91-97 my $hold_borrower = $hold->borrower(); Link Here
91
ok( $hold_borrower, 'Got hold borrower' );
92
ok( $hold_borrower, 'Got hold borrower' );
92
is( $hold_borrower->borrowernumber(), $borrower->borrowernumber(), 'Hold borrower matches correct borrower' );
93
is( $hold_borrower->borrowernumber(), $borrower->borrowernumber(), 'Hold borrower matches correct borrower' );
93
94
94
C4::Context->set_preference( 'ReservesMaxPickUpDelay', '' );
95
t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', '' );
95
$dt = $hold->waiting_expires_on();
96
$dt = $hold->waiting_expires_on();
96
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set" );
97
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set" );
97
98
Lines 99-105 is( $hold->is_waiting, 1, 'The hold is waiting' ); Link Here
99
is( $hold->is_found, 1, 'The hold is found');
100
is( $hold->is_found, 1, 'The hold is found');
100
ok( !$hold->is_in_transit, 'The hold is not in transit' );
101
ok( !$hold->is_in_transit, 'The hold is not in transit' );
101
102
102
C4::Context->set_preference( 'ReservesMaxPickUpDelay', '5' );
103
t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', '5' );
103
$dt = $hold->waiting_expires_on();
104
$dt = $hold->waiting_expires_on();
104
is( $dt->ymd, "2000-01-06",
105
is( $dt->ymd, "2000-01-06",
105
    "Koha::Hold->waiting_expires_on returns DateTime of waitingdate + ReservesMaxPickUpDelay if set" );
106
    "Koha::Hold->waiting_expires_on returns DateTime of waitingdate + ReservesMaxPickUpDelay if set" );
(-)a/t/db_dependent/Holds.t (-6 / +6 lines)
Lines 334-343 $reserve3 = GetReserve( $reserveid3 ); Link Here
334
is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" );
334
is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" );
335
335
336
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber);
336
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber);
337
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 1 );
337
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 );
338
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
338
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
339
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
339
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
340
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 0 );
340
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 );
341
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'damaged', "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" );
341
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'damaged', "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" );
342
ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for damaged item with AllowHoldsOnDamagedItems disabled" );
342
ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for damaged item with AllowHoldsOnDamagedItems disabled" );
343
343
Lines 409-416 is(CanItemBeReserved($borrowernumbers[0], $itemnumber), 'OK', Link Here
409
409
410
410
411
# Test CancelExpiredReserves
411
# Test CancelExpiredReserves
412
C4::Context->set_preference('ExpireReservesMaxPickUpDelay', 1);
412
t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelay', 1);
413
C4::Context->set_preference('ReservesMaxPickUpDelay', 1);
413
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 1);
414
414
415
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time);
415
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time);
416
$year += 1900;
416
$year += 1900;
Lines 427-437 $calendar->insert_single_holiday( Link Here
427
);
427
);
428
$reserve_id = $reserve->{reserve_id};
428
$reserve_id = $reserve->{reserve_id};
429
$dbh->do("UPDATE reserves SET waitingdate = DATE_SUB( NOW(), INTERVAL 5 DAY ), found = 'W', priority = 0 WHERE reserve_id = ?", undef, $reserve_id );
429
$dbh->do("UPDATE reserves SET waitingdate = DATE_SUB( NOW(), INTERVAL 5 DAY ), found = 'W', priority = 0 WHERE reserve_id = ?", undef, $reserve_id );
430
C4::Context->set_preference('ExpireReservesOnHolidays', 0);
430
t::lib::Mocks::mock_preference('ExpireReservesOnHolidays', 0);
431
CancelExpiredReserves();
431
CancelExpiredReserves();
432
my $count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
432
my $count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
433
is( $count, 1, "Waiting reserve beyond max pickup delay *not* canceled on holiday" );
433
is( $count, 1, "Waiting reserve beyond max pickup delay *not* canceled on holiday" );
434
C4::Context->set_preference('ExpireReservesOnHolidays', 1);
434
t::lib::Mocks::mock_preference('ExpireReservesOnHolidays', 1);
435
CancelExpiredReserves();
435
CancelExpiredReserves();
436
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
436
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
437
is( $count, 0, "Waiting reserve beyond max pickup delay canceled on holiday" );
437
is( $count, 0, "Waiting reserve beyond max pickup delay canceled on holiday" );
(-)a/t/db_dependent/HoldsQueue.t (-19 / +16 lines)
Lines 19-24 use Koha::Database; Link Here
19
use Koha::DateUtils;
19
use Koha::DateUtils;
20
use Koha::ItemType;
20
use Koha::ItemType;
21
21
22
use t::lib::Mocks;
22
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
23
24
24
use Koha::ItemTypes;
25
use Koha::ItemTypes;
Lines 67-76 $itemtype or BAIL_OUT("No adequate itemtype"); #FIXME Should be $itemtype = $ite Link Here
67
68
68
#Set up the stage
69
#Set up the stage
69
# Sysprefs and cost matrix
70
# Sysprefs and cost matrix
70
C4::Context->set_preference('HoldsQueueSkipClosed', 0);
71
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
71
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef,
72
t::lib::Mocks::mock_preference('StaticHoldsQueueWeight', join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code));
72
         join( ',', @other_branches, $borrower_branchcode, $least_cost_branch_code));
73
t::lib::Mocks::mock_preference('RandomizeHoldsQueueWeight', 0);
73
$dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'RandomizeHoldsQueueWeight'");
74
74
75
$dbh->do("DELETE FROM transport_cost");
75
$dbh->do("DELETE FROM transport_cost");
76
my $transport_cost_insert_sth = $dbh->prepare("insert into transport_cost (frombranch, tobranch, cost) values (?, ?, ?)");
76
my $transport_cost_insert_sth = $dbh->prepare("insert into transport_cost (frombranch, tobranch, cost) values (?, ?, ?)");
Lines 116-129 AddReserve ( $borrower_branchcode, $borrowernumber, $biblionumber, $bibitems, $ Link Here
116
$dbh->do("UPDATE reserves SET reservedate = DATE_SUB( reservedate, INTERVAL 1 DAY )");
116
$dbh->do("UPDATE reserves SET reservedate = DATE_SUB( reservedate, INTERVAL 1 DAY )");
117
117
118
# Tests
118
# Tests
119
my $use_cost_matrix_sth = $dbh->prepare("UPDATE systempreferences SET value = ? WHERE variable = 'UseTransportCostMatrix'");
120
my $test_sth = $dbh->prepare("SELECT * FROM hold_fill_targets
119
my $test_sth = $dbh->prepare("SELECT * FROM hold_fill_targets
121
                              JOIN tmp_holdsqueue USING (borrowernumber, biblionumber, itemnumber)
120
                              JOIN tmp_holdsqueue USING (borrowernumber, biblionumber, itemnumber)
122
                              JOIN items USING (itemnumber)
121
                              JOIN items USING (itemnumber)
123
                              WHERE borrowernumber = $borrowernumber");
122
                              WHERE borrowernumber = $borrowernumber");
124
123
125
# We have a book available homed in borrower branch, no point fiddling with AutomaticItemReturn
124
# We have a book available homed in borrower branch, no point fiddling with AutomaticItemReturn
126
C4::Context->set_preference('AutomaticItemReturn', 0);
125
t::lib::Mocks::mock_preference('AutomaticItemReturn', 0);
127
test_queue ('take from homebranch',  0, $borrower_branchcode, $borrower_branchcode);
126
test_queue ('take from homebranch',  0, $borrower_branchcode, $borrower_branchcode);
128
test_queue ('take from homebranch',  1, $borrower_branchcode, $borrower_branchcode);
127
test_queue ('take from homebranch',  1, $borrower_branchcode, $borrower_branchcode);
129
128
Lines 132-145 $dbh->do("DELETE FROM hold_fill_targets"); Link Here
132
$dbh->do("DELETE FROM issues WHERE itemnumber IN (SELECT itemnumber FROM items WHERE homebranch = '$borrower_branchcode' AND holdingbranch = '$borrower_branchcode')");
131
$dbh->do("DELETE FROM issues WHERE itemnumber IN (SELECT itemnumber FROM items WHERE homebranch = '$borrower_branchcode' AND holdingbranch = '$borrower_branchcode')");
133
$dbh->do("DELETE FROM items WHERE homebranch = '$borrower_branchcode' AND holdingbranch = '$borrower_branchcode'");
132
$dbh->do("DELETE FROM items WHERE homebranch = '$borrower_branchcode' AND holdingbranch = '$borrower_branchcode'");
134
# test_queue will flush
133
# test_queue will flush
135
C4::Context->set_preference('AutomaticItemReturn', 1);
134
t::lib::Mocks::mock_preference('AutomaticItemReturn', 1);
136
# Not sure how to make this test more difficult - holding branch does not matter
135
# Not sure how to make this test more difficult - holding branch does not matter
137
136
138
$dbh->do("DELETE FROM tmp_holdsqueue");
137
$dbh->do("DELETE FROM tmp_holdsqueue");
139
$dbh->do("DELETE FROM hold_fill_targets");
138
$dbh->do("DELETE FROM hold_fill_targets");
140
$dbh->do("DELETE FROM issues WHERE itemnumber IN (SELECT itemnumber FROM items WHERE homebranch = '$borrower_branchcode')");
139
$dbh->do("DELETE FROM issues WHERE itemnumber IN (SELECT itemnumber FROM items WHERE homebranch = '$borrower_branchcode')");
141
$dbh->do("DELETE FROM items WHERE homebranch = '$borrower_branchcode'");
140
$dbh->do("DELETE FROM items WHERE homebranch = '$borrower_branchcode'");
142
C4::Context->set_preference('AutomaticItemReturn', 0);
141
t::lib::Mocks::mock_preference('AutomaticItemReturn', 0);
143
# We have a book available held in borrower branch
142
# We have a book available held in borrower branch
144
test_queue ('take from holdingbranch', 0, $borrower_branchcode, $borrower_branchcode);
143
test_queue ('take from holdingbranch', 0, $borrower_branchcode, $borrower_branchcode);
145
test_queue ('take from holdingbranch', 1, $borrower_branchcode, $borrower_branchcode);
144
test_queue ('take from holdingbranch', 1, $borrower_branchcode, $borrower_branchcode);
Lines 178-184 $dbh->do("DELETE FROM default_branch_circ_rules"); Link Here
178
$dbh->do("DELETE FROM default_branch_item_rules");
177
$dbh->do("DELETE FROM default_branch_item_rules");
179
$dbh->do("DELETE FROM default_circ_rules");
178
$dbh->do("DELETE FROM default_circ_rules");
180
179
181
C4::Context->set_preference('UseTransportCostMatrix', 0);
180
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0);
182
181
183
$itemtype = Koha::ItemTypes->search->next->itemtype;
182
$itemtype = Koha::ItemTypes->search->next->itemtype;
184
183
Lines 307-313 is( $holds_queue->[1]->{cardnumber}, $borrower2->{cardnumber}, "Holds queue fill Link Here
307
# 1 of which is coming from MPL. Let's enable HoldsQueueSkipClosed
306
# 1 of which is coming from MPL. Let's enable HoldsQueueSkipClosed
308
# and make today a holiday for MPL. When we run it again we should only
307
# and make today a holiday for MPL. When we run it again we should only
309
# have 1 row in the holds queue
308
# have 1 row in the holds queue
310
C4::Context->set_preference('HoldsQueueSkipClosed', 1);
309
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 1);
311
my $today = dt_from_string();
310
my $today = dt_from_string();
312
C4::Calendar->new( branchcode => $branchcodes[0] )->insert_single_holiday(
311
C4::Calendar->new( branchcode => $branchcodes[0] )->insert_single_holiday(
313
    day         => $today->day(),
312
    day         => $today->day(),
Lines 322-328 is( Koha::Calendar->new( branchcode => $branchcodes[0] )->is_holiday( $today ), Link Here
322
C4::HoldsQueue::CreateQueue();
321
C4::HoldsQueue::CreateQueue();
323
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
322
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
324
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
323
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
325
C4::Context->set_preference('HoldsQueueSkipClosed', 0);
324
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
326
325
327
$dbh->do("DELETE FROM default_circ_rules");
326
$dbh->do("DELETE FROM default_circ_rules");
328
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
327
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
Lines 335-345 is( @$holds_queue, 3, "Holds queue filling correct number for holds for default Link Here
335
# one of which is coming from MPL. Let's enable HoldsQueueSkipClosed
334
# one of which is coming from MPL. Let's enable HoldsQueueSkipClosed
336
# and use our previously created holiday for MPL
335
# and use our previously created holiday for MPL
337
# When we run it again we should only have 2 rows in the holds queue
336
# When we run it again we should only have 2 rows in the holds queue
338
C4::Context->set_preference( 'HoldsQueueSkipClosed', 1 );
337
t::lib::Mocks::mock_preference( 'HoldsQueueSkipClosed', 1 );
339
C4::HoldsQueue::CreateQueue();
338
C4::HoldsQueue::CreateQueue();
340
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
339
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
341
is( scalar( @$holds_queue ), 2, "Holds not filled with items from closed libraries" );
340
is( scalar( @$holds_queue ), 2, "Holds not filled with items from closed libraries" );
342
C4::Context->set_preference( 'HoldsQueueSkipClosed', 0 );
341
t::lib::Mocks::mock_preference( 'HoldsQueueSkipClosed', 0 );
343
342
344
# Bug 14297
343
# Bug 14297
345
$itemtype = Koha::ItemTypes->search->next->itemtype;
344
$itemtype = Koha::ItemTypes->search->next->itemtype;
Lines 388-396 $dbh->do(" Link Here
388
    ( '$library_A', '$itemtype', 2, 'homebranch' ), ( '$library_B', '$itemtype', 1, 'homebranch' );
387
    ( '$library_A', '$itemtype', 2, 'homebranch' ), ( '$library_B', '$itemtype', 1, 'homebranch' );
389
");
388
");
390
389
391
$dbh->do( "UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'",
390
t::lib::Mocks::mock_preference('StaticHoldsQueueWeight', join( ',', $library_B, $library_A, $library_C ) );
392
    undef, join( ',', $library_B, $library_A, $library_C ) );
391
t::lib::Mocks::mock_preference('RandomizeHoldsQueueWeight', 0 );
393
$dbh->do( "UPDATE systempreferences SET value = 0 WHERE variable = 'RandomizeHoldsQueueWeight'" );
394
392
395
my $reserve_id = AddReserve ( $library_C, $borrowernumber, $biblionumber, '', 1 );
393
my $reserve_id = AddReserve ( $library_C, $borrowernumber, $biblionumber, '', 1 );
396
C4::HoldsQueue::CreateQueue();
394
C4::HoldsQueue::CreateQueue();
Lines 416-422 $dbh->do("DELETE FROM default_branch_item_rules"); Link Here
416
$dbh->do("DELETE FROM default_circ_rules");
414
$dbh->do("DELETE FROM default_circ_rules");
417
$dbh->do("DELETE FROM branch_item_rules");
415
$dbh->do("DELETE FROM branch_item_rules");
418
416
419
C4::Context->set_preference("UseTransportCostMatrix",1);
417
t::lib::Mocks::mock_preference("UseTransportCostMatrix",1);
420
418
421
my $tc_rs = $schema->resultset('TransportCost');
419
my $tc_rs = $schema->resultset('TransportCost');
422
$tc_rs->create({ frombranch => $library_A, tobranch => $library_B, cost => 0, disable_transfer => 1 });
420
$tc_rs->create({ frombranch => $library_A, tobranch => $library_B, cost => 0, disable_transfer => 1 });
Lines 456-463 sub test_queue { Link Here
456
454
457
    $test_name = "$test_name (".($use_cost_matrix ? "" : "don't ")."use cost matrix)";
455
    $test_name = "$test_name (".($use_cost_matrix ? "" : "don't ")."use cost matrix)";
458
456
459
    $use_cost_matrix_sth->execute($use_cost_matrix);
457
    t::lib::Mocks::mock_preference('UseTransportCostMatrix', $use_cost_matrix);
460
    C4::Context->clear_syspref_cache();
461
    C4::HoldsQueue::CreateQueue();
458
    C4::HoldsQueue::CreateQueue();
462
459
463
    my $results = $dbh->selectall_arrayref($test_sth, { Slice => {} }); # should be only one
460
    my $results = $dbh->selectall_arrayref($test_sth, { Slice => {} }); # should be only one
(-)a/t/db_dependent/Items.t (-11 / +11 lines)
Lines 50-56 subtest 'General Add, Get and Del tests' => sub { Link Here
50
    });
50
    });
51
51
52
    # Create a biblio instance for testing
52
    # Create a biblio instance for testing
53
    C4::Context->set_preference('marcflavour', 'MARC21');
53
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
54
    my ($bibnum, $bibitemnum) = get_biblio();
54
    my ($bibnum, $bibitemnum) = get_biblio();
55
55
56
    # Add an item.
56
    # Add an item.
Lines 111-117 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
111
    });
111
    });
112
112
113
    # Create a new biblio
113
    # Create a new biblio
114
    C4::Context->set_preference('marcflavour', 'MARC21');
114
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
115
    my ($biblionumber, $biblioitemnumber) = get_biblio();
115
    my ($biblionumber, $biblioitemnumber) = get_biblio();
116
116
117
    # Add two items
117
    # Add two items
Lines 136-154 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
136
    push @items, GetItem( $item2_itemnumber );
136
    push @items, GetItem( $item2_itemnumber );
137
137
138
    # Empty OpacHiddenItems
138
    # Empty OpacHiddenItems
139
    C4::Context->set_preference('OpacHiddenItems','');
139
    t::lib::Mocks::mock_preference('OpacHiddenItems','');
140
    ok( !defined( GetHiddenItemnumbers( @items ) ),
140
    ok( !defined( GetHiddenItemnumbers( @items ) ),
141
        "Hidden items list undef if OpacHiddenItems empty");
141
        "Hidden items list undef if OpacHiddenItems empty");
142
142
143
    # Blank spaces
143
    # Blank spaces
144
    C4::Context->set_preference('OpacHiddenItems','  ');
144
    t::lib::Mocks::mock_preference('OpacHiddenItems','  ');
145
    ok( scalar GetHiddenItemnumbers( @items ) == 0,
145
    ok( scalar GetHiddenItemnumbers( @items ) == 0,
146
        "Hidden items list empty if OpacHiddenItems only contains blanks");
146
        "Hidden items list empty if OpacHiddenItems only contains blanks");
147
147
148
    # One variable / value
148
    # One variable / value
149
    $opachiddenitems = "
149
    $opachiddenitems = "
150
        withdrawn: [1]";
150
        withdrawn: [1]";
151
    C4::Context->set_preference( 'OpacHiddenItems', $opachiddenitems );
151
    t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems );
152
    @hidden = GetHiddenItemnumbers( @items );
152
    @hidden = GetHiddenItemnumbers( @items );
153
    ok( scalar @hidden == 1, "Only one hidden item");
153
    ok( scalar @hidden == 1, "Only one hidden item");
154
    is( $hidden[0], $item1_itemnumber, "withdrawn=1 is hidden");
154
    is( $hidden[0], $item1_itemnumber, "withdrawn=1 is hidden");
Lines 156-162 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
156
    # One variable, two values
156
    # One variable, two values
157
    $opachiddenitems = "
157
    $opachiddenitems = "
158
        withdrawn: [1,0]";
158
        withdrawn: [1,0]";
159
    C4::Context->set_preference( 'OpacHiddenItems', $opachiddenitems );
159
    t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems );
160
    @hidden = GetHiddenItemnumbers( @items );
160
    @hidden = GetHiddenItemnumbers( @items );
161
    ok( scalar @hidden == 2, "Two items hidden");
161
    ok( scalar @hidden == 2, "Two items hidden");
162
    is_deeply( \@hidden, \@itemnumbers, "withdrawn=1 and withdrawn=0 hidden");
162
    is_deeply( \@hidden, \@itemnumbers, "withdrawn=1 and withdrawn=0 hidden");
Lines 166-172 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
166
        withdrawn: [1]
166
        withdrawn: [1]
167
        homebranch: [$library2->{branchcode}]
167
        homebranch: [$library2->{branchcode}]
168
    ";
168
    ";
169
    C4::Context->set_preference( 'OpacHiddenItems', $opachiddenitems );
169
    t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems );
170
    @hidden = GetHiddenItemnumbers( @items );
170
    @hidden = GetHiddenItemnumbers( @items );
171
    ok( scalar @hidden == 2, "Two items hidden");
171
    ok( scalar @hidden == 2, "Two items hidden");
172
    is_deeply( \@hidden, \@itemnumbers, "withdrawn=1 and homebranch library2 hidden");
172
    is_deeply( \@hidden, \@itemnumbers, "withdrawn=1 and homebranch library2 hidden");
Lines 244-253 subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { Link Here
244
    my @bi = $biblio->biblioitems();
244
    my @bi = $biblio->biblioitems();
245
    my ( $item ) = $bi[0]->items();
245
    my ( $item ) = $bi[0]->items();
246
246
247
    C4::Context->set_preference( 'item-level_itypes', 0 );
247
    t::lib::Mocks::mock_preference( 'item-level_itypes', 0 );
248
    ok( $item->effective_itemtype() eq 'BIB_LEVEL', '$item->itemtype() returns biblioitem.itemtype when item-level_itypes is disabled' );
248
    ok( $item->effective_itemtype() eq 'BIB_LEVEL', '$item->itemtype() returns biblioitem.itemtype when item-level_itypes is disabled' );
249
249
250
    C4::Context->set_preference( 'item-level_itypes', 1 );
250
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
251
    ok( $item->effective_itemtype() eq 'ITEM_LEVEL', '$item->itemtype() returns items.itype when item-level_itypes is enabled' );
251
    ok( $item->effective_itemtype() eq 'ITEM_LEVEL', '$item->itemtype() returns items.itype when item-level_itypes is enabled' );
252
252
253
    # If itemtype is not defined and item-level_level item types are set
253
    # If itemtype is not defined and item-level_level item types are set
Lines 280-286 subtest 'SearchItems test' => sub { Link Here
280
        source => 'Branch',
280
        source => 'Branch',
281
    });
281
    });
282
282
283
    C4::Context->set_preference('marcflavour', 'MARC21');
283
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
284
    my $cpl_items_before = SearchItemsByField( 'homebranch', $library1->{branchcode});
284
    my $cpl_items_before = SearchItemsByField( 'homebranch', $library1->{branchcode});
285
285
286
    my ($biblionumber) = get_biblio();
286
    my ($biblionumber) = get_biblio();
Lines 444-450 subtest 'Koha::Item(s) tests' => sub { Link Here
444
    });
444
    });
445
445
446
    # Create a biblio and item for testing
446
    # Create a biblio and item for testing
447
    C4::Context->set_preference('marcflavour', 'MARC21');
447
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
448
    my ($bibnum, $bibitemnum) = get_biblio();
448
    my ($bibnum, $bibitemnum) = get_biblio();
449
    my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $library1->{branchcode}, holdingbranch => $library2->{branchcode} } , $bibnum);
449
    my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $library1->{branchcode}, holdingbranch => $library2->{branchcode} } , $bibnum);
450
450
(-)a/t/db_dependent/Koha/Patron/Messages.t (-4 / +5 lines)
Lines 27-32 use Koha::Patron::Message; Link Here
27
use Koha::Patron::Messages;
27
use Koha::Patron::Messages;
28
use Koha::Database;
28
use Koha::Database;
29
29
30
use t::lib::Mocks;
30
use t::lib::TestBuilder;
31
use t::lib::TestBuilder;
31
32
32
my $schema = Koha::Database->new->schema;
33
my $schema = Koha::Database->new->schema;
Lines 38-44 my $patron = $builder->build( { source => 'Borrower', values => { branch Link Here
38
my $nb_of_logaction = get_nb_of_logactions();
39
my $nb_of_logaction = get_nb_of_logactions();
39
my $nb_of_messages = Koha::Patron::Messages->search->count;
40
my $nb_of_messages = Koha::Patron::Messages->search->count;
40
41
41
C4::Context->set_preference('BorrowersLog', 0);
42
t::lib::Mocks::mock_preference('BorrowersLog', 0);
42
my $new_message_1  = Koha::Patron::Message->new(
43
my $new_message_1  = Koha::Patron::Message->new(
43
    {   borrowernumber => $patron->{borrowernumber},
44
    {   borrowernumber => $patron->{borrowernumber},
44
        branchcode     => $library->{branchcode},
45
        branchcode     => $library->{branchcode},
Lines 48-54 my $new_message_1 = Koha::Patron::Message->new( Link Here
48
)->store;
49
)->store;
49
is( get_nb_of_logactions(), $nb_of_logaction, 'With BorrowersLog off, no new log should have been added' );
50
is( get_nb_of_logactions(), $nb_of_logaction, 'With BorrowersLog off, no new log should have been added' );
50
51
51
C4::Context->set_preference('BorrowersLog', 1);
52
t::lib::Mocks::mock_preference('BorrowersLog', 1);
52
my $new_message_2  = Koha::Patron::Message->new(
53
my $new_message_2  = Koha::Patron::Message->new(
53
    {   borrowernumber => $patron->{borrowernumber},
54
    {   borrowernumber => $patron->{borrowernumber},
54
        branchcode     => $library->{branchcode},
55
        branchcode     => $library->{branchcode},
Lines 64-75 is( Koha::Patron::Messages->search->count, $nb_of_messages + 2, 'The 2 messages Link Here
64
my $retrieved_message_1 = Koha::Patron::Messages->find( $new_message_1->message_id );
65
my $retrieved_message_1 = Koha::Patron::Messages->find( $new_message_1->message_id );
65
is( $retrieved_message_1->message, $new_message_1->message, 'Find a message by id should return the correct message' );
66
is( $retrieved_message_1->message, $new_message_1->message, 'Find a message by id should return the correct message' );
66
67
67
C4::Context->set_preference('BorrowersLog', 0);
68
t::lib::Mocks::mock_preference('BorrowersLog', 0);
68
$retrieved_message_1->delete;
69
$retrieved_message_1->delete;
69
is( Koha::Patron::Messages->search->count, $nb_of_messages + 1, 'Delete should have deleted the message 1' );
70
is( Koha::Patron::Messages->search->count, $nb_of_messages + 1, 'Delete should have deleted the message 1' );
70
is( get_nb_of_logactions(), $nb_of_logaction + 1, 'With BorrowersLog off, no new log should have been added when deleting a new message' );
71
is( get_nb_of_logactions(), $nb_of_logaction + 1, 'With BorrowersLog off, no new log should have been added when deleting a new message' );
71
72
72
C4::Context->set_preference('BorrowersLog', 1);
73
t::lib::Mocks::mock_preference('BorrowersLog', 1);
73
$new_message_2->delete;
74
$new_message_2->delete;
74
is( Koha::Patron::Messages->search->count, $nb_of_messages, 'Delete should have deleted the message 2' );
75
is( Koha::Patron::Messages->search->count, $nb_of_messages, 'Delete should have deleted the message 2' );
75
is( get_nb_of_logactions(), $nb_of_logaction + 2, 'With BorrowersLog on, 1 new log should have been added when deleting a new message' );
76
is( get_nb_of_logactions(), $nb_of_logaction + 2, 'With BorrowersLog on, 1 new log should have been added when deleting a new message' );
(-)a/t/db_dependent/Koha_template_plugin_KohaDates.t (-3 / +4 lines)
Lines 5-10 use C4::Context; Link Here
5
use Koha::DateUtils;
5
use Koha::DateUtils;
6
use Test::More tests => 7;
6
use Test::More tests => 7;
7
use Test::MockModule;
7
use Test::MockModule;
8
use t::lib::Mocks;
8
9
9
BEGIN {
10
BEGIN {
10
        use_ok('Koha::Template::Plugin::KohaDates');
11
        use_ok('Koha::Template::Plugin::KohaDates');
Lines 18-37 my $context = C4::Context->new(); Link Here
18
my $filter = Koha::Template::Plugin::KohaDates->new();
19
my $filter = Koha::Template::Plugin::KohaDates->new();
19
ok ($filter, "new()");
20
ok ($filter, "new()");
20
21
21
$context->set_preference( "dateformat", 'iso' );
22
t::lib::Mocks::mock_preference( "dateformat", 'iso' );
22
$context->clear_syspref_cache();
23
$context->clear_syspref_cache();
23
24
24
my $filtered_date = $filter->filter($date);
25
my $filtered_date = $filter->filter($date);
25
is ($filtered_date,$date, "iso conversion") or diag ("iso conversion fails");
26
is ($filtered_date,$date, "iso conversion") or diag ("iso conversion fails");
26
27
27
#$filter = Koha::Template::Plugin::KohaDates->new();
28
#$filter = Koha::Template::Plugin::KohaDates->new();
28
$context->set_preference( "dateformat", 'us' );
29
t::lib::Mocks::mock_preference( "dateformat", 'us' );
29
$context->clear_syspref_cache();
30
$context->clear_syspref_cache();
30
31
31
$filtered_date = $filter->filter($date);
32
$filtered_date = $filter->filter($date);
32
is ($filtered_date,'05/21/1973', "us conversion") or diag ("us conversion fails $filtered_date");
33
is ($filtered_date,'05/21/1973', "us conversion") or diag ("us conversion fails $filtered_date");
33
34
34
$context->set_preference( "dateformat", 'metric' );
35
t::lib::Mocks::mock_preference( "dateformat", 'metric' );
35
$context->clear_syspref_cache();
36
$context->clear_syspref_cache();
36
37
37
$filtered_date = $filter->filter($date);
38
$filtered_date = $filter->filter($date);
(-)a/t/db_dependent/Languages.t (-2 / +3 lines)
Lines 10-15 use Test::More tests => 16; Link Here
10
use List::Util qw(first);
10
use List::Util qw(first);
11
use Data::Dumper;
11
use Data::Dumper;
12
use Test::Warn;
12
use Test::Warn;
13
use t::lib::Mocks;
13
14
14
BEGIN {
15
BEGIN {
15
    use_ok('C4::Languages');
16
    use_ok('C4::Languages');
Lines 27-33 is(C4::Languages::accept_language(),undef, 'test that accept_languages returns u Link Here
27
28
28
ok(C4::Languages::getAllLanguages(), 'test get all languages');
29
ok(C4::Languages::getAllLanguages(), 'test get all languages');
29
30
30
C4::Context->set_preference('AdvancedSearchLanguages', '');
31
t::lib::Mocks::mock_preference('AdvancedSearchLanguages', '');
31
my $all_languages = C4::Languages::getAllLanguages('eng');
32
my $all_languages = C4::Languages::getAllLanguages('eng');
32
ok(@$all_languages > 10, 'retrieved a bunch of languges');
33
ok(@$all_languages > 10, 'retrieved a bunch of languges');
33
34
Lines 37-43 is_deeply($languages, $all_languages, 'getLanguages() and getAllLanguages() retu Link Here
37
$languages = C4::Languages::getLanguages('eng', 1);
38
$languages = C4::Languages::getLanguages('eng', 1);
38
is_deeply($languages, $all_languages, 'getLanguages() and getAllLanguages() with filtering selected but AdvancedSearchLanguages blank return the same list');
39
is_deeply($languages, $all_languages, 'getLanguages() and getAllLanguages() with filtering selected but AdvancedSearchLanguages blank return the same list');
39
40
40
C4::Context->set_preference('AdvancedSearchLanguages', 'ita|eng');
41
t::lib::Mocks::mock_preference('AdvancedSearchLanguages', 'ita|eng');
41
$languages = C4::Languages::getLanguages('eng', 1);
42
$languages = C4::Languages::getLanguages('eng', 1);
42
is(scalar(@$languages), 2, 'getLanguages() filtering using AdvancedSearchLanguages works');
43
is(scalar(@$languages), 2, 'getLanguages() filtering using AdvancedSearchLanguages works');
43
44
(-)a/t/db_dependent/Letters.t (-1 / +1 lines)
Lines 404-410 C4::Bookseller::ModBookseller($bookseller); Link Here
404
$bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
404
$bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
405
405
406
# Ensure that the preference 'LetterLog' is set to logging
406
# Ensure that the preference 'LetterLog' is set to logging
407
C4::Context->set_preference( 'LetterLog', 'on' );
407
t::lib::Mocks::mock_preference( 'LetterLog', 'on' );
408
408
409
{
409
{
410
warning_is {
410
warning_is {
(-)a/t/db_dependent/Members.t (-9 / +10 lines)
Lines 23-28 use Data::Dumper; Link Here
23
use C4::Context;
23
use C4::Context;
24
use Koha::Database;
24
use Koha::Database;
25
25
26
use t::lib::Mocks;
26
use t::lib::TestBuilder;
27
use t::lib::TestBuilder;
27
28
28
BEGIN {
29
BEGIN {
Lines 130-136 ok ( $changedmember->{firstname} eq $CHANGED_FIRSTNAME && Link Here
130
     , "Member Changed")
131
     , "Member Changed")
131
  or diag("Mismatching member details: ".Dumper($member, $changedmember));
132
  or diag("Mismatching member details: ".Dumper($member, $changedmember));
132
133
133
C4::Context->set_preference( 'CardnumberLength', '' );
134
t::lib::Mocks::mock_preference( 'CardnumberLength', '' );
134
C4::Context->clear_syspref_cache();
135
C4::Context->clear_syspref_cache();
135
136
136
my $checkcardnum=C4::Members::checkcardnumber($CARDNUMBER, "");
137
my $checkcardnum=C4::Members::checkcardnumber($CARDNUMBER, "");
Lines 139-145 is ($checkcardnum, "1", "Card No. in use"); Link Here
139
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
140
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
140
is ($checkcardnum, "0", "Card No. not used");
141
is ($checkcardnum, "0", "Card No. not used");
141
142
142
C4::Context->set_preference( 'CardnumberLength', '4' );
143
t::lib::Mocks::mock_preference( 'CardnumberLength', '4' );
143
C4::Context->clear_syspref_cache();
144
C4::Context->clear_syspref_cache();
144
145
145
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
146
$checkcardnum=C4::Members::checkcardnumber($IMPOSSIBLE_CARDNUMBER, "");
Lines 147-159 is ($checkcardnum, "2", "Card number is too long"); Link Here
147
148
148
149
149
150
150
C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'OFF' );
151
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
151
C4::Context->clear_syspref_cache();
152
C4::Context->clear_syspref_cache();
152
153
153
my $notice_email = GetNoticeEmailAddress($member->{'borrowernumber'});
154
my $notice_email = GetNoticeEmailAddress($member->{'borrowernumber'});
154
is ($notice_email, $EMAIL, "GetNoticeEmailAddress returns correct value when AutoEmailPrimaryAddress is off");
155
is ($notice_email, $EMAIL, "GetNoticeEmailAddress returns correct value when AutoEmailPrimaryAddress is off");
155
156
156
C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'emailpro' );
157
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'emailpro' );
157
C4::Context->clear_syspref_cache();
158
C4::Context->clear_syspref_cache();
158
159
159
$notice_email = GetNoticeEmailAddress($member->{'borrowernumber'});
160
$notice_email = GetNoticeEmailAddress($member->{'borrowernumber'});
Lines 278-292 subtest 'GetMemberAccountBalance' => sub { Link Here
278
        'Expected 15 outstanding for both borrowernumber and cardnumber.');
279
        'Expected 15 outstanding for both borrowernumber and cardnumber.');
279
280
280
    # do not count holds charges
281
    # do not count holds charges
281
    C4::Context->set_preference( 'HoldsInNoissuesCharge', '1' );
282
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', '1' );
282
    C4::Context->set_preference( 'ManInvInNoissuesCharge', '0' );
283
    t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', '0' );
283
    my ($total, $total_minus_charges,
284
    my ($total, $total_minus_charges,
284
        $other_charges) = C4::Members::GetMemberAccountBalance(123);
285
        $other_charges) = C4::Members::GetMemberAccountBalance(123);
285
    is( $total, 15 , "Total calculated correctly");
286
    is( $total, 15 , "Total calculated correctly");
286
    is( $total_minus_charges, 15, "Holds charges are not count if HoldsInNoissuesCharge=1");
287
    is( $total_minus_charges, 15, "Holds charges are not count if HoldsInNoissuesCharge=1");
287
    is( $other_charges, 0, "Holds charges are not considered if HoldsInNoissuesCharge=1");
288
    is( $other_charges, 0, "Holds charges are not considered if HoldsInNoissuesCharge=1");
288
289
289
    C4::Context->set_preference( 'HoldsInNoissuesCharge', '0' );
290
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', '0' );
290
    ($total, $total_minus_charges,
291
    ($total, $total_minus_charges,
291
        $other_charges) = C4::Members::GetMemberAccountBalance(123);
292
        $other_charges) = C4::Members::GetMemberAccountBalance(123);
292
    is( $total, 15 , "Total calculated correctly");
293
    is( $total, 15 , "Total calculated correctly");
Lines 308-315 subtest 'purgeSelfRegistration' => sub { Link Here
308
    #purge members in temporary category
309
    #purge members in temporary category
309
    my $c= 'XYZ';
310
    my $c= 'XYZ';
310
    $dbh->do("INSERT IGNORE INTO categories (categorycode) VALUES ('$c')");
311
    $dbh->do("INSERT IGNORE INTO categories (categorycode) VALUES ('$c')");
311
    C4::Context->set_preference('PatronSelfRegistrationDefaultCategory', $c );
312
    t::lib::Mocks::mock_preference('PatronSelfRegistrationDefaultCategory', $c );
312
    C4::Context->set_preference('PatronSelfRegistrationExpireTemporaryAccountsDelay', 360);
313
    t::lib::Mocks::mock_preference('PatronSelfRegistrationExpireTemporaryAccountsDelay', 360);
313
    C4::Members::DeleteExpiredOpacRegistrations();
314
    C4::Members::DeleteExpiredOpacRegistrations();
314
    $dbh->do("INSERT INTO borrowers (surname, address, city, branchcode, categorycode, dateenrolled) VALUES ('Testaabbcc', 'Street 1', 'CITY', ?, '$c', '2014-01-01 01:02:03')", undef, $library1->{branchcode});
315
    $dbh->do("INSERT INTO borrowers (surname, address, city, branchcode, categorycode, dateenrolled) VALUES ('Testaabbcc', 'Street 1', 'CITY', ?, '$c', '2014-01-01 01:02:03')", undef, $library1->{branchcode});
315
    is( C4::Members::DeleteExpiredOpacRegistrations(), 1, 'Test for DeleteExpiredOpacRegistrations');
316
    is( C4::Members::DeleteExpiredOpacRegistrations(), 1, 'Test for DeleteExpiredOpacRegistrations');
(-)a/t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t (-2 / +3 lines)
Lines 5-10 use C4::Context; Link Here
5
use C4::Members;
5
use C4::Members;
6
use Koha::Database;
6
use Koha::Database;
7
7
8
use t::lib::Mocks;
8
use t::lib::TestBuilder;
9
use t::lib::TestBuilder;
9
10
10
my $schema = Koha::Database->schema;
11
my $schema = Koha::Database->schema;
Lines 52-58 $borrower_data{borrowernumber} = $borrowernumber; Link Here
52
my ( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber );
53
my ( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber );
53
is( $total, $enrolmentfee_K, "New kid pay $enrolmentfee_K" );
54
is( $total, $enrolmentfee_K, "New kid pay $enrolmentfee_K" );
54
55
55
C4::Context->set_preference( 'FeeOnChangePatronCategory', 0 );
56
t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 0 );
56
$borrower_data{categorycode} = 'J';
57
$borrower_data{categorycode} = 'J';
57
C4::Members::ModMember( %borrower_data );
58
C4::Members::ModMember( %borrower_data );
58
( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber );
59
( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber );
Lines 60-66 is( $total, $enrolmentfee_K , "Kid growing and become a juvenile, but shouldn't Link Here
60
61
61
$borrower_data{categorycode} = 'K';
62
$borrower_data{categorycode} = 'K';
62
C4::Members::ModMember( %borrower_data );
63
C4::Members::ModMember( %borrower_data );
63
C4::Context->set_preference( 'FeeOnChangePatronCategory', 1 );
64
t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 1 );
64
65
65
$borrower_data{categorycode} = 'J';
66
$borrower_data{categorycode} = 'J';
66
C4::Members::ModMember( %borrower_data );
67
C4::Members::ModMember( %borrower_data );
(-)a/t/db_dependent/QueryParser.t (-1 / +2 lines)
Lines 20-28 use Modern::Perl; Link Here
20
use Test::More tests => 7;
20
use Test::More tests => 7;
21
21
22
use File::Basename;
22
use File::Basename;
23
use t::lib::Mocks;
23
use C4::Context;
24
use C4::Context;
24
25
25
C4::Context->set_preference( "UseQueryParser", 1 );
26
t::lib::Mocks::mock_preference( "UseQueryParser", 1 );
26
my $QParser = C4::Context->queryparser();
27
my $QParser = C4::Context->queryparser();
27
28
28
# Check initialization correctly parsed the config file
29
# Check initialization correctly parsed the config file
(-)a/t/db_dependent/Record.t (-3 / +4 lines)
Lines 5-10 use Modern::Perl; Link Here
5
use Test::More tests => 13;
5
use Test::More tests => 13;
6
use MARC::Record;
6
use MARC::Record;
7
7
8
use t::lib::Mocks;
8
use C4::Context;
9
use C4::Context;
9
10
10
BEGIN {
11
BEGIN {
Lines 16-22 my $dbh = C4::Context->dbh; Link Here
16
$dbh->{AutoCommit} = 0;
17
$dbh->{AutoCommit} = 0;
17
$dbh->{RaiseError} = 1;
18
$dbh->{RaiseError} = 1;
18
19
19
C4::Context->set_preference( "BibtexExportAdditionalFields", q{} );
20
t::lib::Mocks::mock_preference( "BibtexExportAdditionalFields", q{} );
20
21
21
my @marcarray=marc2marc;
22
my @marcarray=marc2marc;
22
is ($marcarray[0],"Feature not yet implemented\n","error works");
23
is ($marcarray[0],"Feature not yet implemented\n","error works");
Lines 115-121 my $test6xml=qq(\@book{testID, Link Here
115
116
116
is ($bibtex, $test6xml, "testing bibtex");
117
is ($bibtex, $test6xml, "testing bibtex");
117
118
118
C4::Context->set_preference( "BibtexExportAdditionalFields", "'\@': 260\$b\ntest: 260\$b" );
119
t::lib::Mocks::mock_preference( "BibtexExportAdditionalFields", "'\@': 260\$b\ntest: 260\$b" );
119
$bibtex = marc2bibtex( $marc, 'testID' );
120
$bibtex = marc2bibtex( $marc, 'testID' );
120
my $test7xml = qq(\@Scholastic{testID,
121
my $test7xml = qq(\@Scholastic{testID,
121
\tauthor = {Rowling, J.K.},
122
\tauthor = {Rowling, J.K.},
Lines 126-132 my $test7xml = qq(\@Scholastic{testID, Link Here
126
}
127
}
127
);
128
);
128
is( $bibtex, $test7xml, "testing bibtex" );
129
is( $bibtex, $test7xml, "testing bibtex" );
129
C4::Context->set_preference( "BibtexExportAdditionalFields", q{} );
130
t::lib::Mocks::mock_preference( "BibtexExportAdditionalFields", q{} );
130
131
131
$marc->append_fields(MARC::Field->new(
132
$marc->append_fields(MARC::Field->new(
132
    '264', '3', '1', b => 'Reprints', c => '2011'
133
    '264', '3', '1', b => 'Reprints', c => '2011'
(-)a/t/db_dependent/Reserves.t (-16 / +16 lines)
Lines 129-149 is($status, "Reserved", "CheckReserves Test 2"); Link Here
129
is($status, "Reserved", "CheckReserves Test 3");
129
is($status, "Reserved", "CheckReserves Test 3");
130
130
131
my $ReservesControlBranch = C4::Context->preference('ReservesControlBranch');
131
my $ReservesControlBranch = C4::Context->preference('ReservesControlBranch');
132
C4::Context->set_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
132
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
133
ok(
133
ok(
134
    'ItemHomeLib' eq GetReservesControlBranch(
134
    'ItemHomeLib' eq GetReservesControlBranch(
135
        { homebranch => 'ItemHomeLib' },
135
        { homebranch => 'ItemHomeLib' },
136
        { branchcode => 'PatronHomeLib' }
136
        { branchcode => 'PatronHomeLib' }
137
    ), "GetReservesControlBranch returns item home branch when set to ItemHomeLibrary"
137
    ), "GetReservesControlBranch returns item home branch when set to ItemHomeLibrary"
138
);
138
);
139
C4::Context->set_preference( 'ReservesControlBranch', 'PatronLibrary' );
139
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' );
140
ok(
140
ok(
141
    'PatronHomeLib' eq GetReservesControlBranch(
141
    'PatronHomeLib' eq GetReservesControlBranch(
142
        { homebranch => 'ItemHomeLib' },
142
        { homebranch => 'ItemHomeLib' },
143
        { branchcode => 'PatronHomeLib' }
143
        { branchcode => 'PatronHomeLib' }
144
    ), "GetReservesControlBranch returns patron home branch when set to PatronLibrary"
144
    ), "GetReservesControlBranch returns patron home branch when set to PatronLibrary"
145
);
145
);
146
C4::Context->set_preference( 'ReservesControlBranch', $ReservesControlBranch );
146
t::lib::Mocks::mock_preference( 'ReservesControlBranch', $ReservesControlBranch );
147
147
148
###
148
###
149
### Regression test for bug 10272
149
### Regression test for bug 10272
Lines 266-272 AddReserve('CPL', $requesters{'CPL'}, $bibnum2, Link Here
266
           $title,      $checkitem, $found);
266
           $title,      $checkitem, $found);
267
267
268
# Ensure that the item's home library controls hold policy lookup
268
# Ensure that the item's home library controls hold policy lookup
269
C4::Context->set_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
269
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
270
270
271
my $messages;
271
my $messages;
272
# Return the CPL item at FPL.  The hold that should be triggered is
272
# Return the CPL item at FPL.  The hold that should be triggered is
Lines 282-288 is( $messages->{ResFound}->{borrowernumber}, Link Here
282
# and RPL imposes no restrictions on whose holds its items can fill.
282
# and RPL imposes no restrictions on whose holds its items can fill.
283
283
284
# Ensure that the preference 'LocalHoldsPriority' is not set (Bug 15244):
284
# Ensure that the preference 'LocalHoldsPriority' is not set (Bug 15244):
285
C4::Context->set_preference( 'LocalHoldsPriority', '' );
285
t::lib::Mocks::mock_preference( 'LocalHoldsPriority', '' );
286
286
287
(undef, $messages, undef, undef) = AddReturn('bug10272_FPL', 'FPL');
287
(undef, $messages, undef, undef) = AddReturn('bug10272_FPL', 'FPL');
288
is( $messages->{ResFound}->{borrowernumber},
288
is( $messages->{ResFound}->{borrowernumber},
Lines 325-331 is( $status, 'Reserved', 'CheckReserves also returns reserve with lookahead'); Link Here
325
325
326
# Test 9761b: Add a reserve with future date, CheckReserve should not return it
326
# Test 9761b: Add a reserve with future date, CheckReserve should not return it
327
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
327
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
328
C4::Context->set_preference('AllowHoldDateInFuture', 1);
328
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
329
$resdate= dt_from_string();
329
$resdate= dt_from_string();
330
$resdate->add_duration(DateTime::Duration->new(days => 4));
330
$resdate->add_duration(DateTime::Duration->new(days => 4));
331
$resdate=output_pref($resdate);
331
$resdate=output_pref($resdate);
Lines 345-357 is( $status, 'Reserved', 'CheckReserves returns future reserve with sufficient l Link Here
345
# Test 9761d: Check ResFound message of AddReturn for future hold
345
# Test 9761d: Check ResFound message of AddReturn for future hold
346
# Note that AddReturn is in Circulation.pm, but this test really pertains to reserves; AddReturn uses the ConfirmFutureHolds pref when calling CheckReserves
346
# Note that AddReturn is in Circulation.pm, but this test really pertains to reserves; AddReturn uses the ConfirmFutureHolds pref when calling CheckReserves
347
# In this test we do not need an issued item; it is just a 'checkin'
347
# In this test we do not need an issued item; it is just a 'checkin'
348
C4::Context->set_preference('ConfirmFutureHolds', 0);
348
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0);
349
(my $doreturn, $messages)= AddReturn('97531','CPL');
349
(my $doreturn, $messages)= AddReturn('97531','CPL');
350
is($messages->{ResFound}//'', '', 'AddReturn does not care about future reserve when ConfirmFutureHolds is off');
350
is($messages->{ResFound}//'', '', 'AddReturn does not care about future reserve when ConfirmFutureHolds is off');
351
C4::Context->set_preference('ConfirmFutureHolds', 3);
351
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 3);
352
($doreturn, $messages)= AddReturn('97531','CPL');
352
($doreturn, $messages)= AddReturn('97531','CPL');
353
is(exists $messages->{ResFound}?1:0, 0, 'AddReturn ignores future reserve beyond ConfirmFutureHolds days');
353
is(exists $messages->{ResFound}?1:0, 0, 'AddReturn ignores future reserve beyond ConfirmFutureHolds days');
354
C4::Context->set_preference('ConfirmFutureHolds', 7);
354
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 7);
355
($doreturn, $messages)= AddReturn('97531','CPL');
355
($doreturn, $messages)= AddReturn('97531','CPL');
356
is(exists $messages->{ResFound}?1:0, 1, 'AddReturn considers future reserve within ConfirmFutureHolds days');
356
is(exists $messages->{ResFound}?1:0, 1, 'AddReturn considers future reserve within ConfirmFutureHolds days');
357
357
Lines 382-389 ok(defined($letter), 'can successfully generate hold slip (bug 10949)'); Link Here
382
# Tests for bug 9788: Does GetReservesFromItemnumber return a future wait?
382
# Tests for bug 9788: Does GetReservesFromItemnumber return a future wait?
383
# 9788a: GetReservesFromItemnumber does not return future next available hold
383
# 9788a: GetReservesFromItemnumber does not return future next available hold
384
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
384
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
385
C4::Context->set_preference('ConfirmFutureHolds', 2);
385
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2);
386
C4::Context->set_preference('AllowHoldDateInFuture', 1);
386
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
387
$resdate= dt_from_string();
387
$resdate= dt_from_string();
388
$resdate->add_duration(DateTime::Duration->new(days => 2));
388
$resdate->add_duration(DateTime::Duration->new(days => 2));
389
$resdate=output_pref($resdate);
389
$resdate=output_pref($resdate);
Lines 435-441 AddReserve('CPL', $requesters{'CPL2'}, $bibnum, Link Here
435
$p = C4::Reserves::CalculatePriority($bibnum);
435
$p = C4::Reserves::CalculatePriority($bibnum);
436
is($p, 2, 'CalculatePriority should now return priority 2');
436
is($p, 2, 'CalculatePriority should now return priority 2');
437
#add another future hold
437
#add another future hold
438
C4::Context->set_preference('AllowHoldDateInFuture', 1);
438
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
439
$resdate= dt_from_string();
439
$resdate= dt_from_string();
440
$resdate->add_duration(DateTime::Duration->new(days => 1));
440
$resdate->add_duration(DateTime::Duration->new(days => 1));
441
AddReserve('CPL',  $requesters{'CPL3'}, $bibnum,
441
AddReserve('CPL',  $requesters{'CPL3'}, $bibnum,
Lines 503-509 is($cancancel, 0, 'Reserve in waiting status cant be canceled'); Link Here
503
####### Testing Bug 13113 - Prevent juvenile/children from reserving ageRestricted material >>>
503
####### Testing Bug 13113 - Prevent juvenile/children from reserving ageRestricted material >>>
504
       ####
504
       ####
505
505
506
C4::Context->set_preference( 'AgeRestrictionMarker', 'FSK|PEGI|Age|K' );
506
t::lib::Mocks::mock_preference( 'AgeRestrictionMarker', 'FSK|PEGI|Age|K' );
507
507
508
#Reserving an not-agerestricted Biblio by a Borrower with no dateofbirth is tested previously.
508
#Reserving an not-agerestricted Biblio by a Borrower with no dateofbirth is tested previously.
509
509
Lines 632-639 is( int( $bz14464_fines ), 42, 'Bug 14464 - Fine applied after cancelling reserv Link Here
632
# tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526)
632
# tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526)
633
#   hold from A pos 1, today, no fut holds: MoveReserve should fill it
633
#   hold from A pos 1, today, no fut holds: MoveReserve should fill it
634
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
634
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
635
C4::Context->set_preference('ConfirmFutureHolds', 0);
635
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0);
636
C4::Context->set_preference('AllowHoldDateInFuture', 1);
636
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
637
AddReserve('CPL',  $borrowernumber, $item_bibnum,
637
AddReserve('CPL',  $borrowernumber, $item_bibnum,
638
    $bibitems,  1, undef, $expdate, $notes, $title, $checkitem, '');
638
    $bibitems,  1, undef, $expdate, $notes, $title, $checkitem, '');
639
MoveReserve( $itemnumber, $borrowernumber );
639
MoveReserve( $itemnumber, $borrowernumber );
Lines 656-662 MoveReserve( $itemnumber, $borrowernumber ); Link Here
656
is( $status, 'Reserved', 'MoveReserve did not fill future hold');
656
is( $status, 'Reserved', 'MoveReserve did not fill future hold');
657
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
657
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
658
#   hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it
658
#   hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it
659
C4::Context->set_preference('ConfirmFutureHolds', 2);
659
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2);
660
AddReserve('CPL',  $borrowernumber, $item_bibnum,
660
AddReserve('CPL',  $borrowernumber, $item_bibnum,
661
    $bibitems,  1, $resdate, $expdate, $notes, $title, $checkitem, '');
661
    $bibitems,  1, $resdate, $expdate, $notes, $title, $checkitem, '');
662
MoveReserve( $itemnumber, $borrowernumber );
662
MoveReserve( $itemnumber, $borrowernumber );
(-)a/t/db_dependent/Suggestions.t (-2 / +3 lines)
Lines 17-22 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use t::lib::Mocks;
20
use C4::Context;
21
use C4::Context;
21
use C4::Members;
22
use C4::Members;
22
use C4::Letters;
23
use C4::Letters;
Lines 344-354 is( @$suggestions, 1, 'DelSuggestion deletes one suggestion' ); Link Here
344
is( $suggestions->[0]->{title}, $del_suggestion->{title}, 'DelSuggestion deletes the correct suggestion' );
345
is( $suggestions->[0]->{title}, $del_suggestion->{title}, 'DelSuggestion deletes the correct suggestion' );
345
346
346
## Bug 11466, making sure GetSupportList() returns itemtypes, even if AdvancedSearchTypes has multiple values
347
## Bug 11466, making sure GetSupportList() returns itemtypes, even if AdvancedSearchTypes has multiple values
347
C4::Context->set_preference("AdvancedSearchTypes", 'itemtypes|loc|ccode');
348
t::lib::Mocks::mock_preference("AdvancedSearchTypes", 'itemtypes|loc|ccode');
348
my $itemtypes1 = C4::Koha::GetSupportList();
349
my $itemtypes1 = C4::Koha::GetSupportList();
349
is(@$itemtypes1, 8, "Purchase suggestion itemtypes collected, multiple AdvancedSearchTypes");
350
is(@$itemtypes1, 8, "Purchase suggestion itemtypes collected, multiple AdvancedSearchTypes");
350
351
351
C4::Context->set_preference("AdvancedSearchTypes", 'itemtypes');
352
t::lib::Mocks::mock_preference("AdvancedSearchTypes", 'itemtypes');
352
my $itemtypes2 = C4::Koha::GetSupportList();
353
my $itemtypes2 = C4::Koha::GetSupportList();
353
is(@$itemtypes2, 8, "Purchase suggestion itemtypes collected, default AdvancedSearchTypes");
354
is(@$itemtypes2, 8, "Purchase suggestion itemtypes collected, default AdvancedSearchTypes");
354
355
(-)a/t/db_dependent/XISBN.t (-4 / +5 lines)
Lines 11-16 use C4::Biblio; Link Here
11
use C4::XISBN;
11
use C4::XISBN;
12
use C4::Context;
12
use C4::Context;
13
use C4::Search;
13
use C4::Search;
14
use t::lib::Mocks;
14
use Test::MockModule;
15
use Test::MockModule;
15
16
16
BEGIN {
17
BEGIN {
Lines 54-61 is( $trial->{biblionumber}, Link Here
54
    $biblionumber1, "Gets biblionumber like the previous test." );
55
    $biblionumber1, "Gets biblionumber like the previous test." );
55
56
56
## Test ThingISBN
57
## Test ThingISBN
57
$context->set_preference( 'ThingISBN', 1 );
58
$contextt::lib::Mocks::mock_preference( 'ThingISBN', 1 );
58
$context->set_preference( 'XISBN', 0 );
59
$contextt::lib::Mocks::mock_preference( 'XISBN', 0 );
59
60
60
my $results_thingisbn;
61
my $results_thingisbn;
61
eval { $results_thingisbn = C4::XISBN::get_xisbns($isbn1); };
62
eval { $results_thingisbn = C4::XISBN::get_xisbns($isbn1); };
Lines 68-75 SKIP: { Link Here
68
}
69
}
69
70
70
## Test XISBN
71
## Test XISBN
71
$context->set_preference( 'ThingISBN', 0 );
72
$contextt::lib::Mocks::mock_preference( 'ThingISBN', 0 );
72
$context->set_preference( 'XISBN', 1 );
73
$contextt::lib::Mocks::mock_preference( 'XISBN', 1 );
73
74
74
my $results_xisbn;
75
my $results_xisbn;
75
eval { $results_xisbn = C4::XISBN::get_xisbns($isbn1); };
76
eval { $results_xisbn = C4::XISBN::get_xisbns($isbn1); };
(-)a/t/db_dependent/default_search_class.pl (-1 / +2 lines)
Lines 24-32 the default search class from the QueryParser object Link Here
24
24
25
=cut
25
=cut
26
26
27
use t::lib::Mocks;
27
use C4::Context;
28
use C4::Context;
28
29
29
C4::Context->set_preference("UseQueryParser","1");
30
t::lib::Mocks::mock_preference("UseQueryParser","1");
30
31
31
my $QParser = C4::Context->queryparser();
32
my $QParser = C4::Context->queryparser();
32
my $default_search_class = $QParser->default_search_class();
33
my $default_search_class = $QParser->default_search_class();
(-)a/t/db_dependent/sysprefs.t (-8 / +8 lines)
Lines 1-4 Link Here
1
#!/usr/bin/perl
1
!/usr/bin/perl
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 20-25 Link Here
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 8;
22
use Test::More tests => 8;
23
use t::lib::Mocks;
23
use C4::Context;
24
use C4::Context;
24
25
25
# Start transaction
26
# Start transaction
Lines 30-39 $dbh->{AutoCommit} = 0; Link Here
30
my $opacheader    = C4::Context->preference('opacheader');
31
my $opacheader    = C4::Context->preference('opacheader');
31
my $newopacheader = "newopacheader";
32
my $newopacheader = "newopacheader";
32
33
33
C4::Context->set_preference( 'OPACHEADER', $newopacheader );
34
t::lib::Mocks::mock_preference( 'OPACHEADER', $newopacheader );
34
is( C4::Context->preference('opacheader'), $newopacheader, 'The pref should have been set correctly' );
35
is( C4::Context->preference('opacheader'), $newopacheader, 'The pref should have been set correctly' );
35
36
36
C4::Context->set_preference( 'opacheader', $opacheader );
37
t::lib::Mocks::mock_preference( 'opacheader', $opacheader );
37
is( C4::Context->preference('OPACHEADER'), $opacheader, 'A pref name should be case insensitive');
38
is( C4::Context->preference('OPACHEADER'), $opacheader, 'A pref name should be case insensitive');
38
39
39
$ENV{OVERRIDE_SYSPREF_opacheader} = 'this is an override';
40
$ENV{OVERRIDE_SYSPREF_opacheader} = 'this is an override';
Lines 46-61 is( Link Here
46
47
47
is( C4::Context->preference('IDoNotExist'), undef, 'Get a non-existent system preference should return undef');
48
is( C4::Context->preference('IDoNotExist'), undef, 'Get a non-existent system preference should return undef');
48
49
49
C4::Context->set_preference( 'IDoNotExist', 'NonExistent' );
50
t::lib::Mocks::mock_preference( 'IDoNotExist', 'NonExistent' );
50
is( C4::Context->preference('IDoNotExist'), 'NonExistent', 'Test creation of non-existent system preference' );
51
is( C4::Context->preference('IDoNotExist'), 'NonExistent', 'Test creation of non-existent system preference' );
51
52
52
C4::Context->set_preference('testpreference', 'abc');
53
t::lib::Mocks::mock_preference('testpreference', 'abc');
53
C4::Context->delete_preference('testpreference');
54
C4::Context->delete_preference('testpreference');
54
is(C4::Context->preference('testpreference'), undef, 'deleting preferences');
55
is(C4::Context->preference('testpreference'), undef, 'deleting preferences');
55
56
56
C4::Context->set_preference('testpreference', 'def');
57
t::lib::Mocks::mock_preference('testpreference', 'def');
57
# Delete from the database, it should still be in cache
58
# Delete from the database, it should still be in cache
58
$dbh->do("DELETE FROM systempreferences WHERE variable='testpreference'");
59
$dbh->do("DELETE FROM  WHERE variable='testpreference'");
59
is(C4::Context->preference('testpreference'), 'def', 'caching preferences');
60
is(C4::Context->preference('testpreference'), 'def', 'caching preferences');
60
C4::Context->clear_syspref_cache();
61
C4::Context->clear_syspref_cache();
61
is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');
62
is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');
62
- 

Return to bug 11998