Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 4; |
20 |
use Test::More tests => 5; |
21 |
use Test::Warn; |
21 |
use Test::Warn; |
22 |
use t::lib::TestBuilder; |
22 |
use t::lib::TestBuilder; |
23 |
|
23 |
|
Lines 211-215
subtest 'export without record_type' => sub {
Link Here
|
211 |
#Depending on your logger config, you might have a warn in your logs |
211 |
#Depending on your logger config, you might have a warn in your logs |
212 |
}; |
212 |
}; |
213 |
|
213 |
|
|
|
214 |
subtest '_get_biblio_for_export' => sub { |
215 |
plan tests => 4; |
216 |
|
217 |
my $biblio = MARC::Record->new(); |
218 |
$biblio->leader('00266nam a22001097a 4500'); |
219 |
$biblio->append_fields( |
220 |
MARC::Field->new('100', ' ', ' ', a => 'Thurber, James'), |
221 |
MARC::Field->new('245', ' ', ' ', a => "The 13 Clocks"), |
222 |
); |
223 |
my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, ''); |
224 |
my $branch_a = $builder->build({ |
225 |
source => 'Branch', |
226 |
value => { |
227 |
} |
228 |
}); |
229 |
my $branch_b = $builder->build({ |
230 |
source => 'Branch', |
231 |
value => { |
232 |
} |
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 |
} |
241 |
}); |
242 |
my $item_branch_b = $builder->build({ |
243 |
source => 'Item', |
244 |
value => { |
245 |
biblionumber => $biblionumber, |
246 |
homebranch => $branch_b->{branchcode}, |
247 |
more_subfields_xml => '', |
248 |
} |
249 |
}); |
250 |
|
251 |
my $record = Koha::Exporter::Record::_get_biblio_for_export( { |
252 |
biblionumber => $biblionumber, |
253 |
export_items => 1, |
254 |
only_export_items_for_branches => undef |
255 |
}); |
256 |
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"); |
258 |
|
259 |
$record = Koha::Exporter::Record::_get_biblio_for_export( { |
260 |
biblionumber => $biblionumber, |
261 |
export_items => 1, |
262 |
only_export_items_for_branches => [$branch_b->{branchcode}] |
263 |
}); |
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"); |
266 |
is($items[0]->subfield('a'),$branch_b->{branchcode},"And the homebranch for that item should be branch_b branchcode"); |
267 |
|
268 |
$record = Koha::Exporter::Record::_get_biblio_for_export( { |
269 |
biblionumber => $biblionumber, |
270 |
export_items => 0, |
271 |
only_export_items_for_branches => [$branch_b->{branchcode}] |
272 |
}); |
273 |
@items = $record->field('952'); |
274 |
is(@items,0,"We should not have any items if we don't request items and pass a branch"); |
275 |
|
276 |
}; |
277 |
|
278 |
|
279 |
|
280 |
|
214 |
$schema->storage->txn_rollback; |
281 |
$schema->storage->txn_rollback; |
215 |
|
282 |
|
216 |
- |
|
|