Bugzilla – Attachment 42316 Details for
Bug 14639
Extend Koha::MetadataRecord to handle serialization format
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14639: (QA followup) make schema mandatory
Bug-14639-QA-followup-make-schema-mandatory.patch (text/plain), 2.61 KB, created by
Tomás Cohen Arazi (tcohen)
on 2015-09-03 13:19:37 UTC
(
hide
)
Description:
Bug 14639: (QA followup) make schema mandatory
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2015-09-03 13:19:37 UTC
Size:
2.61 KB
patch
obsolete
>From 5fdca1b1d79d3bb036771c64a95d6eb23609f59d Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 3 Sep 2015 10:13:18 -0300 >Subject: [PATCH] Bug 14639: (QA followup) make schema mandatory > >This patch makes the 'schema' param mandatory. It is passed in every >call on the current codebase, so it makes no harm now, but makes >the code less error-prone. > >Tests for this situation are added to t/Koha_MetadataRecord.t (schema >param is omitted and new() returns undef and a carped warning). > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/MetadataRecord.pm | 7 ++++++- > t/Koha_MetadataRecord.t | 17 +++++++++++++---- > 2 files changed, 19 insertions(+), 5 deletions(-) > >diff --git a/Koha/MetadataRecord.pm b/Koha/MetadataRecord.pm >index cec2487..8b0d8a4 100644 >--- a/Koha/MetadataRecord.pm >+++ b/Koha/MetadataRecord.pm >@@ -82,8 +82,13 @@ sub new { > return; > } > >+ if (!defined $params->{ schema }) { >+ carp 'No schema passed'; >+ return; >+ } >+ > my $record = $params->{ record }; >- my $schema = $params->{ schema } // 'marc21'; >+ my $schema = $params->{ schema }; > my $format = $params->{ format } // 'MARC'; > my $id = $params->{ id }; > >diff --git a/t/Koha_MetadataRecord.t b/t/Koha_MetadataRecord.t >index a924843..f53e13d 100755 >--- a/t/Koha_MetadataRecord.t >+++ b/t/Koha_MetadataRecord.t >@@ -100,17 +100,26 @@ is($dupkeys, 0, 'No duplicate keys'); > > subtest "new() tests" => sub { > >- plan tests => 12; >+ plan tests => 14; > > # Test default values with a MARC::Record record > my $record = MARC::Record->new(); >- my $metadata_record = new Koha::MetadataRecord({ >- record => $record >+ my $metadata_record; >+ >+ warning_is { $metadata_record = new Koha::MetadataRecord({ >+ record => $record }) } >+ { carped => 'No schema passed' }, >+ "Metadata schema is mandatory, raise a carped warning if omitted"; >+ is( $metadata_record, undef, "Metadata schema is mandatory, return undef if omitted"); >+ >+ $metadata_record = new Koha::MetadataRecord({ >+ record => $record, >+ schema => 'marc21' > }); > > is( ref($metadata_record), 'Koha::MetadataRecord', 'Type correct'); > is( ref($metadata_record->record), 'MARC::Record', 'Record type preserved'); >- is( $metadata_record->schema, 'marc21', 'Metadata schema defaults to marc21'); >+ is( $metadata_record->schema, 'marc21', 'Metadata schema is set to marc21'); > is( $metadata_record->format, 'MARC', 'Serializacion format defaults to marc'); > is( $metadata_record->id, undef, 'id is optional, undef if unspecifid'); > >-- >2.5.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14639
:
41315
|
41316
|
41357
|
41358
|
41360
|
41361
|
41386
|
41387
|
42312
|
42313
| 42316