Bugzilla – Attachment 41357 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: (regression tests) Extend Koha::MetadataRecord to handle serialization format and record id
Bug-14639-regression-tests-Extend-KohaMetadataReco.patch (text/plain), 3.77 KB, created by
Tomás Cohen Arazi (tcohen)
on 2015-08-04 16:08:18 UTC
(
hide
)
Description:
Bug 14639: (regression tests) Extend Koha::MetadataRecord to handle serialization format and record id
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2015-08-04 16:08:18 UTC
Size:
3.77 KB
patch
obsolete
>From fe790a8fc2541a43f75dffe98322a926ec61d6de Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 3 Aug 2015 11:37:36 -0300 >Subject: [PATCH] Bug 14639: (regression tests) Extend Koha::MetadataRecord to > handle serialization format and record id > >In order to use Koha::MetadataRecord as a container for moving records >around it is important to let it carry the serialization format >of the record object it was built with, so it is easier and cheaper to >make decisions about records. > >This patch introduces regression tests for the changes to be made. >The 'format' param is introduced, and also sets default values: > schema => 'marc21' > format => 'marc' > >A new (optional) 'id' param is added so the record carries its own id outside >of it. > >The default behaviour is preserved, and no changes are needed in places >Koha::MetadataRecord is used. >->new also returns undef if no record is passed, and raises a carped warning. > >To test: >- Apply the patch >- Run the new tests > $ prove t/Koha_MetadataRecord.t >=> FAIL: Tests shoud fail as the changes are not implemented on Koha::MetadataRecord >--- > t/Koha_MetadataRecord.t | 55 ++++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 52 insertions(+), 3 deletions(-) > >diff --git a/t/Koha_MetadataRecord.t b/t/Koha_MetadataRecord.t >index 33cdeb1..6f135aa 100755 >--- a/t/Koha_MetadataRecord.t >+++ b/t/Koha_MetadataRecord.t >@@ -17,10 +17,10 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-use warnings; >+use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; >+use Test::Warn; > > BEGIN { > use_ok('Koha::MetadataRecord'); >@@ -96,3 +96,52 @@ foreach my $field (@$hash) { > is_deeply($hash, $samplehash, 'Generated hash correctly'); > my $dupkeys = grep { $_ > 1 } values %fieldkeys; > is($dupkeys, 0, 'No duplicate keys'); >+ >+ >+subtest "new() tests" => sub { >+ >+ plan tests => 12; >+ >+ # Test default values with a MARC::Record record >+ my $record = MARC::Record->new(); >+ my $metadata_record = new Koha::MetadataRecord({ >+ record => $record >+ }); >+ >+ 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->format, 'marc', 'Serializacion format defaults to marc'); >+ is( $metadata_record->id, undef, 'id is optional, undef if unspecifid'); >+ >+ # Test passed values, also no constraint on record type >+ my $weird_record = {}; >+ bless $weird_record, 'Weird::Class'; >+ >+ $metadata_record = new Koha::MetadataRecord({ >+ record => $weird_record, >+ schema => 'something', >+ format => 'else', >+ id => 'an id' >+ }); >+ >+ is( ref($metadata_record), 'Koha::MetadataRecord', 'Type correct'); >+ is( ref($metadata_record->record), 'Weird::Class', 'Record type preserved'); >+ is( $metadata_record->schema, 'something', 'Metadata schema correctly set'); >+ is( $metadata_record->format, 'else', 'Serializacion format correctly set'); >+ is( $metadata_record->id, 'an id', 'The id correctly set'); >+ >+ # Having a record object is mandatory >+ warning_is { $metadata_record = new Koha::MetadataRecord({ >+ record => undef, >+ schema => 'something', >+ format => 'else', >+ id => 'an id' >+ }) } >+ { carped => 'No record passed' }, >+ 'Undefined record raises carped warning'; >+ >+ is( $metadata_record, undef, 'record object mandatory') >+}; >+ >+1; >-- >2.5.0
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