Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 7; |
20 |
use Test::More tests => 9; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
|
22 |
|
23 |
use List::MoreUtils qw( uniq ); |
23 |
use List::MoreUtils qw( uniq ); |
Lines 391-393
subtest 'deletedbiblio_metadata' => sub {
Link Here
|
391 |
is( $moved, $biblionumber, 'Found in deletedbiblio_metadata' ); |
391 |
is( $moved, $biblionumber, 'Found in deletedbiblio_metadata' ); |
392 |
}; |
392 |
}; |
393 |
|
393 |
|
394 |
- |
394 |
subtest '_set_marc_field' => sub { |
|
|
395 |
plan tests => 6; |
396 |
|
397 |
my $record = MARC::Record->new(); |
398 |
|
399 |
C4::Biblio::_set_marc_field($record, '999$9', 'foobar'); |
400 |
my @fields = $record->field('999'); |
401 |
is(scalar @fields, 1, 'Created one field'); |
402 |
my @subfields = $fields[0]->subfield('9'); |
403 |
is(scalar @subfields, 1, 'Created one subfield'); |
404 |
is($subfields[0], 'foobar', 'Created subfield has correct value'); |
405 |
|
406 |
C4::Biblio::_set_marc_field($record, '999$9', 'foobaz'); |
407 |
@fields = $record->field('999'); |
408 |
is(scalar @fields, 1, 'No additional field created'); |
409 |
@subfields = $fields[0]->subfield('9'); |
410 |
is(scalar @subfields, 1, 'No additional subfield created'); |
411 |
is($subfields[0], 'foobaz', 'Subfield value has been changed'); |
412 |
}; |
413 |
|
414 |
subtest 'MarcFieldForCreatorAndModifier' => sub { |
415 |
plan tests => 8; |
416 |
|
417 |
t::lib::Mocks::mock_preference('MarcFieldForCreatorId', '998$a'); |
418 |
t::lib::Mocks::mock_preference('MarcFieldForCreatorName', '998$b'); |
419 |
t::lib::Mocks::mock_preference('MarcFieldForModifierId', '998$c'); |
420 |
t::lib::Mocks::mock_preference('MarcFieldForModifierName', '998$d'); |
421 |
my $c4_context = Test::MockModule->new('C4::Context'); |
422 |
$c4_context->mock('userenv', sub { return { number => 123, firstname => 'John', surname => 'Doe'}; }); |
423 |
|
424 |
my $record = MARC::Record->new(); |
425 |
my ($biblionumber) = C4::Biblio::AddBiblio($record, ''); |
426 |
|
427 |
$record = GetMarcBiblio({biblionumber => $biblionumber}); |
428 |
is($record->subfield('998', 'a'), 123, '998$a = 123'); |
429 |
is($record->subfield('998', 'b'), 'John Doe', '998$b = John Doe'); |
430 |
is($record->subfield('998', 'c'), 123, '998$c = 123'); |
431 |
is($record->subfield('998', 'd'), 'John Doe', '998$d = John Doe'); |
432 |
|
433 |
$c4_context->mock('userenv', sub { return { number => 321, firstname => 'Jane', surname => 'Doe'}; }); |
434 |
C4::Biblio::ModBiblio($record, $biblionumber, ''); |
435 |
|
436 |
$record = GetMarcBiblio({biblionumber => $biblionumber}); |
437 |
is($record->subfield('998', 'a'), 123, '998$a = 123'); |
438 |
is($record->subfield('998', 'b'), 'John Doe', '998$b = John Doe'); |
439 |
is($record->subfield('998', 'c'), 321, '998$c = 321'); |
440 |
is($record->subfield('998', 'd'), 'Jane Doe', '998$d = Jane Doe'); |
441 |
}; |