|
Link Here
|
| 22 |
use Test::NoWarnings; |
22 |
use Test::NoWarnings; |
| 23 |
use Test::More tests => 5; |
23 |
use Test::More tests => 5; |
| 24 |
use Test::Exception; |
24 |
use Test::Exception; |
|
|
25 |
use Test::Warn; |
| 25 |
|
26 |
|
| 26 |
use t::lib::TestBuilder; |
27 |
use t::lib::TestBuilder; |
| 27 |
use t::lib::Mocks; |
28 |
use t::lib::Mocks; |
|
Link Here
|
| 92 |
|
93 |
|
| 93 |
subtest 'check_fixed_length' => sub { |
94 |
subtest 'check_fixed_length' => sub { |
| 94 |
|
95 |
|
| 95 |
plan tests => 6; |
96 |
plan tests => 9; |
| 96 |
$schema->storage->txn_begin; |
97 |
$schema->storage->txn_begin; |
| 97 |
|
98 |
|
|
|
99 |
# Check empty string (no valid metadata) |
| 100 |
my $extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new( { metadata => q{} } ); |
| 101 |
warning_like { $extractor->check_fixed_length } qr/not a MARC::Record object/, 'Extractor should warn'; |
| 102 |
|
| 103 |
# Check empty object |
| 98 |
my $record = MARC::Record->new; |
104 |
my $record = MARC::Record->new; |
|
|
105 |
$extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new( { metadata => $record } ); |
| 106 |
my $result = $extractor->check_fixed_length; |
| 107 |
is( scalar @{ $result->{passed} }, 0, 'No passed fields' ); |
| 108 |
is( scalar @{ $result->{failed} }, 0, 'No failed fields' ); |
| 109 |
|
| 99 |
$record->append_fields( |
110 |
$record->append_fields( |
| 100 |
MARC::Field->new( '005', '0123456789012345' ), |
111 |
MARC::Field->new( '005', '0123456789012345' ), |
| 101 |
); |
112 |
); |
| 102 |
my $biblio = $builder->build_sample_biblio; |
113 |
my $biblio = $builder->build_sample_biblio; |
| 103 |
ModBiblio( $record, $biblio->biblionumber ); |
114 |
ModBiblio( $record, $biblio->biblionumber ); |
| 104 |
|
115 |
|
| 105 |
my $extractor; |
|
|
| 106 |
$extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new( { biblio => $biblio } ); |
116 |
$extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new( { biblio => $biblio } ); |
| 107 |
my $result = $extractor->check_fixed_length; |
117 |
$result = $extractor->check_fixed_length; |
| 108 |
is( $result->{passed}->[0], '005', 'Check first passed field' ); |
118 |
is( $result->{passed}->[0], '005', 'Check first passed field' ); |
| 109 |
is( scalar @{ $result->{failed} }, 0, 'Check failed count' ); |
119 |
is( scalar @{ $result->{failed} }, 0, 'Check failed count' ); |
| 110 |
|
120 |
|
| 111 |
- |
|
|