Bugzilla – Attachment 96703 Details for
Bug 24321
Make objects.search use mappings from Koha::Object(s)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24321: Add Koha::Objects->attributes_from_api
Bug-24321-Add-KohaObjects-attributesfromapi.patch (text/plain), 2.18 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-12-31 14:52:15 UTC
(
hide
)
Description:
Bug 24321: Add Koha::Objects->attributes_from_api
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-12-31 14:52:15 UTC
Size:
2.18 KB
patch
obsolete
>From 7ff5624850a8d582d680e621168d7ccdb58bb912 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 31 Dec 2019 09:16:17 -0300 >Subject: [PATCH] Bug 24321: Add Koha::Objects->attributes_from_api > >This patch makes the 'attributes_from_api' method from the singular >class available from the result set class. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Objects.t >=> SUCCESS: Tests pass! >4. Sign off :-D >5. Yeah, I skipped 3 :-P >--- > Koha/Objects.pm | 15 +++++++++++++++ > t/db_dependent/Koha/Objects.t | 24 +++++++++++++++++++++++- > 2 files changed, 38 insertions(+), 1 deletion(-) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 31387e1442..165511a42a 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -320,6 +320,21 @@ sub to_api { > return [ map { $_->to_api } $self->as_list ]; > } > >+=head3 attributes_from_api >+ >+ my $attributes = $objects->attributes_from_api( $api_attributes ); >+ >+Translates attributes from the API to DBIC >+ >+=cut >+ >+sub attributes_from_api { >+ my ( $self, $attributes ) = @_; >+ >+ $self->{_singular_object} ||= $self->object_class->new(); >+ return $self->{_singular_object}->attributes_from_api( $attributes ); >+} >+ > =head3 Koha::Objects->_wrap > > wraps the DBIC object in a corresponding Koha object >diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t >index 592ab40866..e6e5db2289 100644 >--- a/t/db_dependent/Koha/Objects.t >+++ b/t/db_dependent/Koha/Objects.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 17; >+use Test::More tests => 18; > use Test::Exception; > use Test::Warn; > >@@ -330,3 +330,25 @@ subtest "TO_JSON() tests" => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest "attributes_from_api() tests" => sub { >+ >+ plan tests => 1; >+ >+ $schema->storage->txn_begin; >+ >+ my $cities_rs = Koha::Cities->new; >+ my $city = Koha::City->new; >+ >+ my $api_attributes = { >+ name => 'Cordoba', >+ postal_code => 5000 >+ }; >+ >+ is_deeply( >+ $cities_rs->attributes_from_api($api_attributes), >+ $city->attributes_from_api($api_attributes) >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.24.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 24321
:
96703
|
96704
|
96705
|
96706
|
96707
|
96708
|
96709
|
96710
|
96711
|
96712
|
96713
|
96714
|
96715
|
96716
|
96717
|
96718
|
96719
|
96720
|
96721
|
96722
|
96744
|
96840
|
96841
|
96842
|
96843
|
96844
|
96845
|
96846
|
96847
|
96848
|
96849
|
96850
|
96851
|
96852
|
96874
|
96875
|
96876
|
96877
|
96878
|
96879
|
96880
|
96881
|
96882
|
96883
|
96884
|
96885
|
96886
|
96887
|
96939
|
96940
|
96941
|
96942
|
96943
|
96944
|
96945
|
96946
|
96947
|
96948
|
96949
|
96950
|
96951
|
96952