Link Here
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::NoWarnings; |
22 |
use Test::NoWarnings; |
23 |
use Test::More tests => 4; |
23 |
use Test::More tests => 5; |
24 |
use Test::Exception; |
24 |
use Test::Exception; |
25 |
|
25 |
|
26 |
use t::lib::TestBuilder; |
26 |
use t::lib::TestBuilder; |
27 |
use t::lib::Mocks; |
27 |
use t::lib::Mocks; |
28 |
|
28 |
|
|
|
29 |
use C4::Biblio qw(ModBiblio); |
29 |
use Koha::Biblio::Metadata::Extractor; |
30 |
use Koha::Biblio::Metadata::Extractor; |
|
|
31 |
use Koha::Biblio::Metadata::Extractor::MARC::MARC21; |
30 |
|
32 |
|
31 |
my $schema = Koha::Database->schema; |
33 |
my $schema = Koha::Database->schema; |
32 |
my $builder = t::lib::TestBuilder->new; |
34 |
my $builder = t::lib::TestBuilder->new; |
Link Here
|
87 |
is( $extractor->get_normalized_oclc, "" ); |
89 |
is( $extractor->get_normalized_oclc, "" ); |
88 |
|
90 |
|
89 |
}; |
91 |
}; |
90 |
- |
92 |
|
|
|
93 |
subtest 'check_fixed_length' => sub { |
94 |
|
95 |
plan tests => 6; |
96 |
$schema->storage->txn_begin; |
97 |
|
98 |
my $record = MARC::Record->new; |
99 |
$record->append_fields( |
100 |
MARC::Field->new( '005', '0123456789012345' ), |
101 |
); |
102 |
my $biblio = $builder->build_sample_biblio; |
103 |
ModBiblio( $record, $biblio->biblionumber ); |
104 |
|
105 |
my $extractor; |
106 |
$extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new( { biblio => $biblio } ); |
107 |
my $result = $extractor->check_fixed_length; |
108 |
is( $result->{passed}->[0], '005', 'Check first passed field' ); |
109 |
is( scalar @{ $result->{failed} }, 0, 'Check failed count' ); |
110 |
|
111 |
$record->append_fields( |
112 |
MARC::Field->new( '006', '01234567890123456789' ), # too long |
113 |
MARC::Field->new( '007', 'a1234567' ), |
114 |
MARC::Field->new( '007', 'm12345678' ), # should be 8 or 23 |
115 |
MARC::Field->new( '007', 'm1234567890123456789012' ), |
116 |
); |
117 |
|
118 |
# Passing latest record changes via metadata now |
119 |
$extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new( { metadata => $record } ); |
120 |
$result = $extractor->check_fixed_length; |
121 |
is( $result->{passed}->[1], '007', 'Check second passed field' ); |
122 |
is( $result->{passed}->[2], '007', 'Check third passed field' ); |
123 |
is( $result->{failed}->[0], '006', 'Check first failed field' ); |
124 |
is( $result->{failed}->[1], '007', 'Check second failed field' ); |
125 |
|
126 |
$schema->storage->txn_rollback; |
127 |
}; |