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

(-)a/t/db_dependent/Exporter/Record.t (-47 / +52 lines)
Lines 217-277 subtest '_get_biblio_for_export' => sub { Link Here
217
    my $biblio = MARC::Record->new();
217
    my $biblio = MARC::Record->new();
218
    $biblio->leader('00266nam a22001097a 4500');
218
    $biblio->leader('00266nam a22001097a 4500');
219
    $biblio->append_fields(
219
    $biblio->append_fields(
220
        MARC::Field->new('100', ' ', ' ', a => 'Thurber, James'),
220
        MARC::Field->new( '100', ' ', ' ', a => 'Thurber, James' ),
221
        MARC::Field->new('245', ' ', ' ', a => "The 13 Clocks"),
221
        MARC::Field->new( '245', ' ', ' ', a => "The 13 Clocks" ),
222
    );
222
    );
223
    my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
223
    my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' );
224
    my $branch_a = $builder->build({
224
    my $branch_a = $builder->build({source => 'Branch',});
225
        source => 'Branch',
225
    my $branch_b = $builder->build({source => 'Branch',});
226
        value => {
226
    my $item_branch_a = $builder->build(
227
        }
227
        {
228
    });
228
            source => 'Item',
229
    my $branch_b = $builder->build({
229
            value  => {
230
        source => 'Branch',
230
                biblionumber       => $biblionumber,
231
        value => {
231
                homebranch         => $branch_a->{branchcode},
232
        }
232
                more_subfields_xml => '',
233
    });
233
            }
234
    my $item_branch_a = $builder->build({
235
        source => 'Item',
236
        value => {
237
            biblionumber => $biblionumber,
238
            homebranch   => $branch_a->{branchcode},
239
            more_subfields_xml => '',
240
        }
234
        }
241
    });
235
    );
242
    my $item_branch_b = $builder->build({
236
    my $item_branch_b = $builder->build(
243
        source => 'Item',
237
        {
244
        value => {
238
            source => 'Item',
245
            biblionumber => $biblionumber,
239
            value  => {
246
            homebranch   => $branch_b->{branchcode},
240
                biblionumber       => $biblionumber,
247
            more_subfields_xml => '',
241
                homebranch         => $branch_b->{branchcode},
242
                more_subfields_xml => '',
243
            }
248
        }
244
        }
249
    });
245
    );
250
246
251
    my $record = Koha::Exporter::Record::_get_biblio_for_export( {
247
    my $record = Koha::Exporter::Record::_get_biblio_for_export(
252
        biblionumber => $biblionumber,
248
        {
253
        export_items => 1,
249
            biblionumber                   => $biblionumber,
254
        only_export_items_for_branches => undef
250
            export_items                   => 1,
255
    });
251
            only_export_items_for_branches => undef
252
        }
253
    );
256
    my @items = $record->field('952');
254
    my @items = $record->field('952');
257
    is(scalar @items,2,"We should retrieve all items if we don't pass specific branches and request items");
255
    is( scalar @items, 2, "We should retrieve all items if we don't pass specific branches and request items" );
258
256
259
    $record = Koha::Exporter::Record::_get_biblio_for_export( {
257
    $record = Koha::Exporter::Record::_get_biblio_for_export(
260
        biblionumber => $biblionumber,
258
        {
261
        export_items => 1,
259
            biblionumber                   => $biblionumber,
262
        only_export_items_for_branches => [$branch_b->{branchcode}]
260
            export_items                   => 1,
263
    });
261
            only_export_items_for_branches => [ $branch_b->{branchcode} ]
262
        }
263
    );
264
    @items = $record->field('952');
264
    @items = $record->field('952');
265
    is(scalar @items,1,"We should retrieve only item for branch_b item if we request items and pass branch");
265
    is( scalar @items, 1, "We should retrieve only item for branch_b item if we request items and pass branch" );
266
    is($items[0]->subfield('a'),$branch_b->{branchcode},"And the homebranch for that item should be branch_b branchcode");
266
    is(
267
        $items[0]->subfield('a'),
268
        $branch_b->{branchcode},
269
        "And the homebranch for that item should be branch_b branchcode"
270
    );
267
271
268
    $record = Koha::Exporter::Record::_get_biblio_for_export( {
272
    $record = Koha::Exporter::Record::_get_biblio_for_export(
269
        biblionumber => $biblionumber,
273
        {
270
        export_items => 0,
274
            biblionumber                   => $biblionumber,
271
        only_export_items_for_branches => [$branch_b->{branchcode}]
275
            export_items                   => 0,
272
    });
276
            only_export_items_for_branches => [ $branch_b->{branchcode} ]
277
        }
278
    );
273
    @items = $record->field('952');
279
    @items = $record->field('952');
274
    is(@items,0,"We should not have any items if we don't request items and pass a branch");
280
    is( scalar @items, 0, "We should not have any items if we don't request items and pass a branch");
275
281
276
};
282
};
277
283
278
- 

Return to bug 18201