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

(-)a/t/db_dependent/Biblio.t (-2 / +54 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 15;
20
use Test::More tests => 16;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
use List::MoreUtils qw( uniq );
23
use List::MoreUtils qw( uniq );
Lines 40-45 my $schema = Koha::Database->new->schema; Link Here
40
$schema->storage->txn_begin;
40
$schema->storage->txn_begin;
41
my $dbh = C4::Context->dbh;
41
my $dbh = C4::Context->dbh;
42
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
42
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
43
t::lib::Mocks::mock_preference('AutoAddSystemControlNumberAndMARCOrgCode', 0);
43
44
44
my $builder = t::lib::TestBuilder->new;
45
my $builder = t::lib::TestBuilder->new;
45
46
Lines 825-830 subtest "LinkBibHeadingsToAuthorities record generation tests" => sub { Link Here
825
    );
826
    );
826
};
827
};
827
828
829
subtest 'AutoAddSystemControlNumberAndMARCOrgCode' => sub {
830
    plan tests => 4;
831
    t::lib::Mocks::mock_preference('MARCOrgCode', 'OrgKoha');
832
833
    my $biblio = $builder->build_sample_biblio();
834
    my $record = $biblio->metadata->record;
835
    my $field;
836
837
    $field = $record->field('001');
838
    if ($field) {
839
        $record->delete_fields($field);
840
    }
841
    $field = $record->field('003');
842
    if ($field) {
843
        $record->delete_fields($field);
844
    }
845
846
    $record->insert_fields_ordered(MARC::Field->new('001', '123123'));
847
    $record->insert_fields_ordered(MARC::Field->new('003', 'OrgExternal'));
848
849
    my ($biblionumber) = AddBiblio($record->clone, '');
850
    my $saved_record = GetMarcBiblio({ biblionumber => $biblionumber });
851
852
    is(
853
        $saved_record->field('001')->data(),
854
        '123123',
855
        'Record system control number has retained it\'s original value'
856
    );
857
    is(
858
        $saved_record->field('003')->data(),
859
        'OrgExternal',
860
        'Record control number identifier has retained it\'s original value'
861
    );
862
863
    t::lib::Mocks::mock_preference('AutoAddSystemControlNumberAndMARCOrgCode', 1);
864
865
    ($biblionumber) = AddBiblio($record, '');
866
    $saved_record = GetMarcBiblio({ biblionumber => $biblionumber });
867
868
    is(
869
        $saved_record->field('001')->data(),
870
        $biblionumber,
871
        'Record system control number been set to Koha biblionumber'
872
    );
873
874
    is(
875
        $saved_record->field('003')->data(),
876
        'OrgKoha',
877
        'Record control number identifier been set to MARCOrgCode syspref value'
878
    );
879
};
880
828
# Cleanup
881
# Cleanup
829
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
882
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
830
$schema->storage->txn_rollback;
883
$schema->storage->txn_rollback;
831
- 

Return to bug 29694