Lines 17-29
Link Here
|
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
19 |
|
|
|
20 |
# Note that at present this test is almost identical to the one testing |
21 |
# the encapsulating method in Koha::MetadataRecord. |
22 |
|
20 |
use strict; |
23 |
use strict; |
21 |
use warnings; |
24 |
use warnings; |
22 |
|
25 |
|
23 |
use Test::More tests => 4; |
26 |
use Test::More tests => 3; |
24 |
|
27 |
|
25 |
BEGIN { |
28 |
BEGIN { |
26 |
use_ok('Koha::Record'); |
29 |
use_ok('Koha::Util::MARC'); |
27 |
} |
30 |
} |
28 |
|
31 |
|
29 |
my $marcrecord = MARC::Record->new; |
32 |
my $marcrecord = MARC::Record->new; |
Lines 33-42
$marcrecord->add_fields(
Link Here
|
33 |
[ '150', ' ', ' ', a => 'Cooking' ], |
36 |
[ '150', ' ', ' ', a => 'Cooking' ], |
34 |
[ '450', ' ', ' ', a => 'Cookery', z => 'Instructional manuals' ], |
37 |
[ '450', ' ', ' ', a => 'Cookery', z => 'Instructional manuals' ], |
35 |
); |
38 |
); |
36 |
my $record = Koha::Record->new({ 'record' => $marcrecord }); |
|
|
37 |
|
38 |
is(ref($record), 'Koha::Record', 'Created valid Koha::Record object'); |
39 |
|
40 |
my $samplehash = [ |
39 |
my $samplehash = [ |
41 |
{ |
40 |
{ |
42 |
'field' => [ |
41 |
'field' => [ |
Lines 82-90
my $samplehash = [
Link Here
|
82 |
} |
81 |
} |
83 |
]; |
82 |
]; |
84 |
|
83 |
|
85 |
my $hash = $record->createMarcHash(); |
84 |
my $hash = Koha::Util::MARC::createMergeHash($marcrecord); |
86 |
my %fieldkeys; |
85 |
my %fieldkeys; |
87 |
require Data::Dumper; |
|
|
88 |
foreach my $field (@$hash) { |
86 |
foreach my $field (@$hash) { |
89 |
$fieldkeys{delete $field->{'field'}->[0]->{'key'}}++; |
87 |
$fieldkeys{delete $field->{'field'}->[0]->{'key'}}++; |
90 |
if (defined $field->{'field'}->[0]->{'subfield'}) { |
88 |
if (defined $field->{'field'}->[0]->{'subfield'}) { |
Lines 97-99
foreach my $field (@$hash) {
Link Here
|
97 |
is_deeply($hash, $samplehash, 'Generated hash correctly'); |
95 |
is_deeply($hash, $samplehash, 'Generated hash correctly'); |
98 |
my $dupkeys = grep { $_ > 1 } values %fieldkeys; |
96 |
my $dupkeys = grep { $_ > 1 } values %fieldkeys; |
99 |
is($dupkeys, 0, 'No duplicate keys'); |
97 |
is($dupkeys, 0, 'No duplicate keys'); |
100 |
- |
98 |
|