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

(-)a/t/db_dependent/OAI/Sets.t (-2 / +54 lines)
Lines 18-24 Link Here
18
18
19
use Modern::Perl;
19
use Modern::Perl;
20
20
21
use Test::More tests => 152;
21
use Test::More tests => 153;
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 560-565 is($oai_setsVH->[0]->{id}, $setVH_id, 'id is ok'); Link Here
560
is($oai_setsVH->[0]->{spec}, $setVH->{spec}, 'id is ok');
560
is($oai_setsVH->[0]->{spec}, $setVH->{spec}, 'id is ok');
561
is($oai_setsVH->[0]->{name}, $setVH->{name}, 'id is ok');
561
is($oai_setsVH->[0]->{name}, $setVH->{name}, 'id is ok');
562
562
563
subtest 'OAI-PMH:AutoUpdateSetsEmbedItemData' => sub {
564
565
    plan tests => 6;
566
567
    t::lib::Mocks::mock_preference( 'OAI-PMH:AutoUpdateSetsEmbedItemData', 0 );
568
569
    #Create a set
570
    my $setFIC = {
571
        'spec' => 'Set where collection code is FIC',
572
        'name' => 'FIC'
573
    };
574
    my $setFIC_id = AddOAISet($setFIC);
575
576
    #Create mappings : 'ccode' should be 'FIC'
577
    my $mappingsFIC;
578
    $mappingsFIC = [
579
        {
580
            marcfield    => '952',
581
            marcsubfield => '8',
582
            operator     => 'equal',
583
            marcvalue    => 'FIC'
584
        }
585
    ];
586
    ModOAISetMappings( $setFIC_id, $mappingsFIC );
587
588
    # Create biblio with 'FIC' item
589
    my $biblio_FIC = $builder->build_sample_biblio();
590
    my $item       = $builder->build_sample_item(
591
        {
592
            biblionumber => $biblio_FIC->biblionumber,
593
            ccode        => 'FIC'
594
        }
595
    );
596
597
    #Update
598
    my $recordFIC = GetMarcBiblio( { biblionumber => $biblio_FIC->biblionumber } );
599
    UpdateOAISetsBiblio( $biblio_FIC->biblionumber, $recordFIC );
600
601
    #is biblio attached to setFIC ?
602
    my $oai_setsFIC = GetOAISetsBiblio( $biblio_FIC->biblionumber );
603
    is( $oai_setsFIC->[0]->{id},   undef, 'id is ok' );
604
    is( $oai_setsFIC->[0]->{spec}, undef, 'id is ok' );
605
    is( $oai_setsFIC->[0]->{name}, undef, 'id is ok' );
606
607
    t::lib::Mocks::mock_preference( 'OAI-PMH:AutoUpdateSetsEmbedItemData', 1 );
608
    UpdateOAISetsBiblio( $biblio_FIC->biblionumber, $recordFIC );
609
610
    #is biblio attached to setFIC ?
611
    $oai_setsFIC = GetOAISetsBiblio( $biblio_FIC->biblionumber );
612
    is( $oai_setsFIC->[0]->{id},   $setFIC_id,      'id is ok' );
613
    is( $oai_setsFIC->[0]->{spec}, $setFIC->{spec}, 'id is ok' );
614
    is( $oai_setsFIC->[0]->{name}, $setFIC->{name}, 'id is ok' );
615
};
563
616
564
# ---------- Testing CalcOAISetsBiblio ----------
617
# ---------- Testing CalcOAISetsBiblio ----------
565
ok (!defined(CalcOAISetsBiblio), 'CalcOAISetsBiblio without argument is undef');
618
ok (!defined(CalcOAISetsBiblio), 'CalcOAISetsBiblio without argument is undef');
566
- 

Return to bug 25460