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

(-)a/t/db_dependent/Koha/Item.t (-15 / +16 lines)
Lines 156-173 subtest "as_marc_field() tests" => sub { Link Here
156
};
156
};
157
157
158
subtest 'pickup_locations' => sub {
158
subtest 'pickup_locations' => sub {
159
    plan tests => 114;
159
    plan tests => 60;
160
160
161
    $schema->storage->txn_begin;
161
    $schema->storage->txn_begin;
162
162
163
    my $dbh = C4::Context->dbh;
163
    my $dbh = C4::Context->dbh;
164
164
165
    # Cleanup database
165
    my $nb_libraries = Koha::Libraries->count;
166
    Koha::Holds->search->delete;
167
    $dbh->do('DELETE FROM issues');
168
    Koha::Patrons->search->delete;
169
    Koha::Items->search->delete;
170
    Koha::Libraries->search->delete;
171
    Koha::CirculationRules->search->delete;
166
    Koha::CirculationRules->search->delete;
172
    Koha::CirculationRules->set_rules(
167
    Koha::CirculationRules->set_rules(
173
        {
168
        {
Lines 192-197 subtest 'pickup_locations' => sub { Link Here
192
    my $group2_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } );
187
    my $group2_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } );
193
    my $group2_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } );
188
    my $group2_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } );
194
189
190
    our @branchcodes = (
191
        $library1->branchcode, $library2->branchcode,
192
        $library3->branchcode, $library4->branchcode
193
    );
194
195
    my $item1 = $builder->build_sample_item(
195
    my $item1 = $builder->build_sample_item(
196
        {
196
        {
197
            homebranch    => $library1->branchcode,
197
            homebranch    => $library1->branchcode,
Lines 214-230 subtest 'pickup_locations' => sub { Link Here
214
    my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } );
214
    my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } );
215
215
216
    my $results = {
216
    my $results = {
217
        "1-1-1-any" => 3,
217
        "1-1-1-any" => 3 + $nb_libraries,
218
        "1-1-1-holdgroup" => 2,
218
        "1-1-1-holdgroup" => 2,
219
        "1-1-1-patrongroup" => 2,
219
        "1-1-1-patrongroup" => 2,
220
        "1-1-1-homebranch" => 1,
220
        "1-1-1-homebranch" => 1,
221
        "1-1-1-holdingbranch" => 1,
221
        "1-1-1-holdingbranch" => 1,
222
        "1-1-2-any" => 3,
222
        "1-1-2-any" => 3 + $nb_libraries,
223
        "1-1-2-holdgroup" => 2,
223
        "1-1-2-holdgroup" => 2,
224
        "1-1-2-patrongroup" => 2,
224
        "1-1-2-patrongroup" => 2,
225
        "1-1-2-homebranch" => 1,
225
        "1-1-2-homebranch" => 1,
226
        "1-1-2-holdingbranch" => 1,
226
        "1-1-2-holdingbranch" => 1,
227
        "1-1-3-any" => 3,
227
        "1-1-3-any" => 3 + $nb_libraries,
228
        "1-1-3-holdgroup" => 2,
228
        "1-1-3-holdgroup" => 2,
229
        "1-1-3-patrongroup" => 2,
229
        "1-1-3-patrongroup" => 2,
230
        "1-1-3-homebranch" => 1,
230
        "1-1-3-homebranch" => 1,
Lines 234-240 subtest 'pickup_locations' => sub { Link Here
234
        "1-4-1-patrongroup" => 0,
234
        "1-4-1-patrongroup" => 0,
235
        "1-4-1-homebranch" => 0,
235
        "1-4-1-homebranch" => 0,
236
        "1-4-1-holdingbranch" => 0,
236
        "1-4-1-holdingbranch" => 0,
237
        "1-4-2-any" => 3,
237
        "1-4-2-any" => 3 + $nb_libraries,
238
        "1-4-2-holdgroup" => 2,
238
        "1-4-2-holdgroup" => 2,
239
        "1-4-2-patrongroup" => 1,
239
        "1-4-2-patrongroup" => 1,
240
        "1-4-2-homebranch" => 1,
240
        "1-4-2-homebranch" => 1,
Lines 249-255 subtest 'pickup_locations' => sub { Link Here
249
        "3-1-1-patrongroup" => 0,
249
        "3-1-1-patrongroup" => 0,
250
        "3-1-1-homebranch" => 0,
250
        "3-1-1-homebranch" => 0,
251
        "3-1-1-holdingbranch" => 0,
251
        "3-1-1-holdingbranch" => 0,
252
        "3-1-2-any" => 3,
252
        "3-1-2-any" => 3 + $nb_libraries,
253
        "3-1-2-holdgroup" => 1,
253
        "3-1-2-holdgroup" => 1,
254
        "3-1-2-patrongroup" => 2,
254
        "3-1-2-patrongroup" => 2,
255
        "3-1-2-homebranch" => 0,
255
        "3-1-2-homebranch" => 0,
Lines 264-275 subtest 'pickup_locations' => sub { Link Here
264
        "3-4-1-patrongroup" => 0,
264
        "3-4-1-patrongroup" => 0,
265
        "3-4-1-homebranch" => 0,
265
        "3-4-1-homebranch" => 0,
266
        "3-4-1-holdingbranch" => 0,
266
        "3-4-1-holdingbranch" => 0,
267
        "3-4-2-any" => 3,
267
        "3-4-2-any" => 3 + $nb_libraries,
268
        "3-4-2-holdgroup" => 1,
268
        "3-4-2-holdgroup" => 1,
269
        "3-4-2-patrongroup" => 1,
269
        "3-4-2-patrongroup" => 1,
270
        "3-4-2-homebranch" => 0,
270
        "3-4-2-homebranch" => 0,
271
        "3-4-2-holdingbranch" => 1,
271
        "3-4-2-holdingbranch" => 1,
272
        "3-4-3-any" => 3,
272
        "3-4-3-any" => 3 + $nb_libraries,
273
        "3-4-3-holdgroup" => 1,
273
        "3-4-3-holdgroup" => 1,
274
        "3-4-3-patrongroup" => 1,
274
        "3-4-3-patrongroup" => 1,
275
        "3-4-3-homebranch" => 0,
275
        "3-4-3-homebranch" => 0,
Lines 294-299 subtest 'pickup_locations' => sub { Link Here
294
        my $ha_value=$ha==3?'holdgroup':($ha==2?'any':'homebranch');
294
        my $ha_value=$ha==3?'holdgroup':($ha==2?'any':'homebranch');
295
295
296
        foreach my $pickup_location (@pl) {
296
        foreach my $pickup_location (@pl) {
297
            next
298
              unless grep { $pickup_location eq $_ } @branchcodes;
297
            is( ref($pickup_location), 'Koha::Library', 'Object type is correct' );
299
            is( ref($pickup_location), 'Koha::Library', 'Object type is correct' );
298
        }
300
        }
299
        ok(
301
        ok(
300
- 

Return to bug 26984