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

(-)a/Koha/MetadataRecord.pm (-1 / +6 lines)
Lines 82-89 sub new { Link Here
82
        return;
82
        return;
83
    }
83
    }
84
84
85
    if (!defined $params->{ schema }) {
86
        carp 'No schema passed';
87
        return;
88
    }
89
85
    my $record = $params->{ record };
90
    my $record = $params->{ record };
86
    my $schema = $params->{ schema } // 'marc21';
91
    my $schema = $params->{ schema };
87
    my $format = $params->{ format } // 'MARC';
92
    my $format = $params->{ format } // 'MARC';
88
    my $id     = $params->{ id };
93
    my $id     = $params->{ id };
89
94
(-)a/t/Koha_MetadataRecord.t (-5 / +13 lines)
Lines 100-116 is($dupkeys, 0, 'No duplicate keys'); Link Here
100
100
101
subtest "new() tests" => sub {
101
subtest "new() tests" => sub {
102
102
103
    plan tests => 12;
103
    plan tests => 14;
104
104
105
    # Test default values with a MARC::Record record
105
    # Test default values with a MARC::Record record
106
    my $record = MARC::Record->new();
106
    my $record = MARC::Record->new();
107
    my $metadata_record = new Koha::MetadataRecord({
107
    my $metadata_record;
108
        record => $record
108
109
    warning_is { $metadata_record = new Koha::MetadataRecord({
110
                        record => $record }) }
111
               { carped => 'No schema passed' },
112
        "Metadata schema is mandatory, raise a carped warning if omitted";
113
    is( $metadata_record, undef, "Metadata schema is mandatory, return undef if omitted");
114
115
    $metadata_record = new Koha::MetadataRecord({
116
        record => $record,
117
        schema => 'marc21'
109
    });
118
    });
110
119
111
    is( ref($metadata_record), 'Koha::MetadataRecord', 'Type correct');
120
    is( ref($metadata_record), 'Koha::MetadataRecord', 'Type correct');
112
    is( ref($metadata_record->record), 'MARC::Record', 'Record type preserved');
121
    is( ref($metadata_record->record), 'MARC::Record', 'Record type preserved');
113
    is( $metadata_record->schema, 'marc21', 'Metadata schema defaults to marc21');
122
    is( $metadata_record->schema, 'marc21', 'Metadata schema is set to marc21');
114
    is( $metadata_record->format, 'MARC', 'Serializacion format defaults to marc');
123
    is( $metadata_record->format, 'MARC', 'Serializacion format defaults to marc');
115
    is( $metadata_record->id, undef, 'id is optional, undef if unspecifid');
124
    is( $metadata_record->id, undef, 'id is optional, undef if unspecifid');
116
125
117
- 

Return to bug 14639