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 125-132 AddReturn( $item1->{barcode} ); Link Here
125
125
126
        my $hold_allowed_from_home_library = 1;
126
        my $hold_allowed_from_home_library = 1;
127
        my $hold_allowed_from_any_libraries = 2;
127
        my $hold_allowed_from_any_libraries = 2;
128
        my $sth_delete_rules = $dbh->prepare(q|DELETE FROM default_circ_rules|);
129
        my $sth_insert_rule = $dbh->prepare(q|INSERT INTO default_circ_rules(singleton, holdallowed, hold_fulfillment_policy, returnbranch) VALUES ('singleton', ?, 'any', 'homebranch');|);
130
128
131
        subtest 'Item is available at a different library' => sub {
129
        subtest 'Item is available at a different library' => sub {
132
            plan tests => 4;
130
            plan tests => 4;
Lines 142-149 AddReturn( $item1->{barcode} ); Link Here
142
            #FIXME: ReservesControlBranch is not checked in these subs we are testing
140
            #FIXME: ReservesControlBranch is not checked in these subs we are testing
143
141
144
            {
142
            {
145
                $sth_delete_rules->execute;
143
                set_holdallowed_rule( $hold_allowed_from_home_library );
146
                $sth_insert_rule->execute( $hold_allowed_from_home_library );
147
144
148
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
145
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
149
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
146
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
Lines 155-162 AddReturn( $item1->{barcode} ); Link Here
155
            }
152
            }
156
153
157
            {
154
            {
158
                $sth_delete_rules->execute;
155
                set_holdallowed_rule( $hold_allowed_from_any_libraries );
159
                $sth_insert_rule->execute( $hold_allowed_from_any_libraries );
160
156
161
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
157
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
162
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
158
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
Lines 182-189 AddReturn( $item1->{barcode} ); Link Here
182
            #ReservesControlBranch is not checked in these subs we are testing?
178
            #ReservesControlBranch is not checked in these subs we are testing?
183
179
184
            {
180
            {
185
                $sth_delete_rules->execute;
181
                set_holdallowed_rule( $hold_allowed_from_home_library );
186
                $sth_insert_rule->execute( $hold_allowed_from_home_library );
187
182
188
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
183
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
189
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
184
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
Lines 195-202 AddReturn( $item1->{barcode} ); Link Here
195
            }
190
            }
196
191
197
            {
192
            {
198
                $sth_delete_rules->execute;
193
                set_holdallowed_rule( $hold_allowed_from_any_libraries );
199
                $sth_insert_rule->execute( $hold_allowed_from_any_libraries );
200
194
201
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
195
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
202
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
196
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
Lines 253-255 is( $is, 1, "Item can be held, items in transit are not available" ); Link Here
253
247
254
# Cleanup
248
# Cleanup
255
$schema->storage->txn_rollback;
249
$schema->storage->txn_rollback;
256
- 
250
251
sub set_holdallowed_rule {
252
    my ( $holdallowed ) = @_;
253
    Koha::CirculationRules->set_rules(
254
        {
255
            branchcode   => undef,
256
            categorycode => undef,
257
            itemtype     => undef,
258
            rules        => {
259
                holdallowed              => $holdallowed,
260
                hold_fulfillment_policy  => 'any',
261
                returnbranch             => 'homebranch',
262
            }
263
        }
264
    );
265
}

Return to bug 18928