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

(-)a/t/db_dependent/Circulation/Branch.t (-6 lines)
Lines 176-187 Koha::CirculationRules->set_rules( Link Here
176
    }
176
    }
177
);
177
);
178
178
179
$query = q|
180
    INSERT INTO default_circ_rules
181
    (singleton, holdallowed, returnbranch)
182
    VALUES( ?, ?, ? )
183
|;
184
$dbh->do( $query, {}, 'singleton', 3, 'homebranch' );
185
Koha::CirculationRules->set_rules(
179
Koha::CirculationRules->set_rules(
186
    {
180
    {
187
        branchcode   => undef,
181
        branchcode   => undef,
(-)a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t (-4 lines)
Lines 37-47 $schema->storage->txn_begin; Link Here
37
37
38
our $dbh = C4::Context->dbh;
38
our $dbh = C4::Context->dbh;
39
39
40
$dbh->do(q|DELETE FROM branch_item_rules|);
41
$dbh->do(q|DELETE FROM issues|);
40
$dbh->do(q|DELETE FROM issues|);
42
$dbh->do(q|DELETE FROM default_branch_circ_rules|);
43
$dbh->do(q|DELETE FROM default_circ_rules|);
44
$dbh->do(q|DELETE FROM default_branch_item_rules|);
45
$dbh->do(q|DELETE FROM issuingrules|);
41
$dbh->do(q|DELETE FROM issuingrules|);
46
42
47
my $builder = t::lib::TestBuilder->new();
43
my $builder = t::lib::TestBuilder->new();
(-)a/t/db_dependent/Circulation/TooMany.t (-4 lines)
Lines 43-52 $dbh->do(q|DELETE FROM branches|); Link Here
43
$dbh->do(q|DELETE FROM categories|);
43
$dbh->do(q|DELETE FROM categories|);
44
$dbh->do(q|DELETE FROM accountlines|);
44
$dbh->do(q|DELETE FROM accountlines|);
45
$dbh->do(q|DELETE FROM itemtypes|);
45
$dbh->do(q|DELETE FROM itemtypes|);
46
$dbh->do(q|DELETE FROM branch_item_rules|);
47
$dbh->do(q|DELETE FROM default_branch_circ_rules|);
48
$dbh->do(q|DELETE FROM default_circ_rules|);
49
$dbh->do(q|DELETE FROM default_branch_item_rules|);
50
$dbh->do(q|DELETE FROM issuingrules|);
46
$dbh->do(q|DELETE FROM issuingrules|);
51
Koha::CirculationRules->search()->delete();
47
Koha::CirculationRules->search()->delete();
52
48
(-)a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t (-11 / +20 lines)
Lines 126-133 AddReturn( $item1->{barcode} ); Link Here
126
126
127
        my $hold_allowed_from_home_library = 1;
127
        my $hold_allowed_from_home_library = 1;
128
        my $hold_allowed_from_any_libraries = 2;
128
        my $hold_allowed_from_any_libraries = 2;
129
        my $sth_delete_rules = $dbh->prepare(q|DELETE FROM default_circ_rules|);
130
        my $sth_insert_rule = $dbh->prepare(q|INSERT INTO default_circ_rules(singleton, holdallowed, hold_fulfillment_policy, returnbranch) VALUES ('singleton', ?, 'any', 'homebranch');|);
131
129
132
        subtest 'Item is available at a different library' => sub {
130
        subtest 'Item is available at a different library' => sub {
133
            plan tests => 4;
131
            plan tests => 4;
Lines 144-151 AddReturn( $item1->{barcode} ); Link Here
144
            #FIXME: ReservesControlBranch is not checked in these subs we are testing
142
            #FIXME: ReservesControlBranch is not checked in these subs we are testing
145
143
146
            {
144
            {
147
                $sth_delete_rules->execute;
145
                set_holdallowed_rule( $hold_allowed_from_home_library );
148
                $sth_insert_rule->execute( $hold_allowed_from_home_library );
149
146
150
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
147
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
151
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
148
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
Lines 157-164 AddReturn( $item1->{barcode} ); Link Here
157
            }
154
            }
158
155
159
            {
156
            {
160
                $sth_delete_rules->execute;
157
                set_holdallowed_rule( $hold_allowed_from_any_libraries );
161
                $sth_insert_rule->execute( $hold_allowed_from_any_libraries );
162
158
163
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
159
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
164
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
160
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
Lines 185-192 AddReturn( $item1->{barcode} ); Link Here
185
            #ReservesControlBranch is not checked in these subs we are testing?
181
            #ReservesControlBranch is not checked in these subs we are testing?
186
182
187
            {
183
            {
188
                $sth_delete_rules->execute;
184
                set_holdallowed_rule( $hold_allowed_from_home_library );
189
                $sth_insert_rule->execute( $hold_allowed_from_home_library );
190
185
191
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
186
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
192
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
187
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
Lines 198-205 AddReturn( $item1->{barcode} ); Link Here
198
            }
193
            }
199
194
200
            {
195
            {
201
                $sth_delete_rules->execute;
196
                set_holdallowed_rule( $hold_allowed_from_any_libraries );
202
                $sth_insert_rule->execute( $hold_allowed_from_any_libraries );
203
197
204
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
198
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
205
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
199
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
Lines 256-258 is( $is, 1, "Item can be held, items in transit are not available" ); Link Here
256
250
257
# Cleanup
251
# Cleanup
258
$schema->storage->txn_rollback;
252
$schema->storage->txn_rollback;
259
- 
253
254
sub set_holdallowed_rule {
255
    my ( $holdallowed ) = @_;
256
    Koha::CirculationRules->set_rules(
257
        {
258
            branchcode   => undef,
259
            categorycode => undef,
260
            itemtype     => undef,
261
            rules        => {
262
                holdallowed              => $holdallowed,
263
                hold_fulfillment_policy  => 'any',
264
                returnbranch             => 'homebranch',
265
            }
266
        }
267
    );
268
}

Return to bug 18928