Bugzilla – Attachment 56238 Details for
Bug 16965
Add the Koha::Objects->search_related method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16965: Add Koha::Objects->search_related
Bug-16965-Add-KohaObjects-searchrelated.patch (text/plain), 2.65 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-10-12 09:39:08 UTC
(
hide
)
Description:
Bug 16965: Add Koha::Objects->search_related
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-10-12 09:39:08 UTC
Size:
2.65 KB
patch
obsolete
>From f5abfe7af9953f377532045559bf10c093dd1d56 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 22 Jul 2016 17:20:08 +0100 >Subject: [PATCH] Bug 16965: Add Koha::Objects->search_related >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >In order to search on relations, we need this new method. > >Test plan: >Confirm that the changes in Objects.t make sense and that the tests >pass. > >Tested all 3 patches together, followed test plan, result OK >Signed-off-by: Marc Véron <veron@veron.ch> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Objects.pm | 13 +++++++++++++ > t/db_dependent/Koha/Objects.t | 13 ++++++++++++- > 2 files changed, 25 insertions(+), 1 deletion(-) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 97436ad..26dec34 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -130,6 +130,19 @@ sub search { > } > } > >+=head3 search_related >+ >+ my @objects = Koha::Objects->search_related( $rel_name, $cond?, \%attrs? ); >+ >+Searches the specified relationship, optionally specifying a condition and attributes for matching records. >+ >+=cut >+ >+sub search_related { >+ my ( $self, @params ) = @_; >+ return $self->_resultset->search_related( @params ); >+} >+ > =head3 Koha::Objects->count(); > > my @objects = Koha::Objects->count($params); >diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t >index 3551caa..c20fe6c 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 => 3; >+use Test::More tests => 4; > > use Koha::Authority::Types; > use Koha::Cities; >@@ -51,5 +51,16 @@ subtest 'update' => sub { > is( Koha::Cities->search( { city_country => 'UK' } )->count, 0, 'Koha::Objects->update should have updated the 3 rows' ); > }; > >+subtest 'search_related' => sub { >+ plan tests => 3; >+ my $builder = t::lib::TestBuilder->new; >+ my $patron_1 = $builder->build( { source => 'Borrower' } ); >+ my $patron_2 = $builder->build( { source => 'Borrower' } ); >+ my $libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode'); >+ is( $libraries->count, 2, 'Koha::Objects->search_related should work as expected' ); >+ is( $libraries->next->branchcode, $patron_1->{branchcode}, 'Koha::Objects->search_related should work as expected' ); >+ is( $libraries->next->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' ); >+}; >+ > $schema->storage->txn_rollback; > 1; >-- >2.10.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 16965
:
53656
|
53673
|
53777
|
56009
|
56010
|
56011
|
56238
|
56239
|
56240
|
56372
|
56373
|
56374
|
56375
|
56650
|
56651
|
56652
|
56653