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

(-)a/t/db_dependent/OAI/Sets.t (-2 / +56 lines)
Lines 18-24 Link Here
18
18
19
use Modern::Perl;
19
use Modern::Perl;
20
20
21
use Test::More tests => 144;
21
use Test::More tests => 146;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
use MARC::Record;
24
use MARC::Record;
Lines 587-590 UpdateOAISetsBiblio($biblionumberNotVH, $record); Link Here
587
my @setsNotEq = CalcOAISetsBiblio($record);
587
my @setsNotEq = CalcOAISetsBiblio($record);
588
is_deeply(@setsNotEq, $setNotVH_id, 'The $record only belongs to $setNotVH');
588
is_deeply(@setsNotEq, $setNotVH_id, 'The $record only belongs to $setNotVH');
589
589
590
# ---------- Testing CalcOAISetsBiblio with repeated field ----------
591
592
# Delete all existing sets to avoid false positives
593
my $all_sets = GetOAISets;
594
foreach my $set ( @$all_sets ) {
595
    DelOAISet( $set->{'id'} );
596
}
597
598
# Create a MARC record with a repeated field 374
599
my $record_rep = MARC::Record->new;
600
$record_rep->add_fields(
601
    [ '001', '1234' ],
602
    [ '100', ' ', ' ', a => 'N., N.' ],
603
    [ '374', ' ', ' ', a => 'A' ],
604
    [ '374', ' ', ' ', a => 'B' ]
605
);
606
607
# Create a set
608
my $setRep = {
609
    'spec' => 'Set where 374a equals a given letter',
610
    'name' => 'Rep'
611
};
612
my $setRep_id = AddOAISet($setRep);
613
# Create a mapping : 374$a should be "A"
614
my $mappingRepA = [
615
    {
616
        marcfield => '374',
617
        marcsubfield => 'a',
618
        operator => 'equal',
619
        marcvalue => 'A',
620
    },
621
];
622
# Add the mapping to the set
623
ModOAISetMappings($setRep_id, $mappingRepA);
624
625
# Get a list of set ids the record belongs to
626
my @setsRepA = CalcOAISetsBiblio($record_rep);
627
is_deeply(\@setsRepA, [$setRep_id], 'The $record belongs to $setRep_id (matching on first field)');
628
629
# Create another mapping : 374$a should now be "B"
630
my $mappingRepB = [
631
    {
632
        marcfield => '374',
633
        marcsubfield => 'a',
634
        operator => 'equal',
635
        marcvalue => 'B',
636
    },
637
];
638
# Replace the first mapping with the second one
639
ModOAISetMappings($setRep_id, $mappingRepB);
640
641
# Get a list of set ids the record belongs to
642
my @setsRepB = CalcOAISetsBiblio($record_rep);
643
is_deeply(\@setsRepB, [$setRep_id], 'The $record belongs to $setRep_id (matching on second field)');
644
590
$schema->storage->txn_rollback;
645
$schema->storage->txn_rollback;
591
- 

Return to bug 24531