Bugzilla – Attachment 33848 Details for
Bug 13019
Add base classes on which to build Koha objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13019 [QA Followup] - Allow find() and search() to be called as static methods
SIGNED-OFF-Bug-13019-QA-Followup---Allow-find-and-.patch (text/plain), 2.32 KB, created by
Kyle M Hall (khall)
on 2014-11-24 12:58:29 UTC
(
hide
)
Description:
Bug 13019 [QA Followup] - Allow find() and search() to be called as static methods
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2014-11-24 12:58:29 UTC
Size:
2.32 KB
patch
obsolete
>From ccdaf66a2db35a0abd62726a6fcb5bf160bff86c Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 21 Nov 2014 11:40:48 -0500 >Subject: [PATCH] [SIGNED-OFF] Bug 13019 [QA Followup] - Allow find() and search() to be called as static methods > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Objects.pm | 13 +++++++++---- > t/db_dependent/Borrowers.t | 6 +++--- > 2 files changed, 12 insertions(+), 7 deletions(-) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 8c17665..5d2d6d0 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -105,7 +105,7 @@ sub search { > > } > else { >- my $class = ref( $self ); >+ my $class = ref($self) ? ref($self) : $self; > my $rs = $self->_resultset()->search($params); > > return $class->new_from_dbic($rs); >@@ -202,10 +202,15 @@ Returns the internal resultset or creates it if undefined > sub _resultset { > my ($self) = @_; > >- $self->{_resultset} ||= >- Koha::Database->new()->schema()->resultset( $self->type() ); >+ if ( ref($self) ) { >+ $self->{_resultset} ||= >+ Koha::Database->new()->schema()->resultset( $self->type() ); > >- $self->{_resultset}; >+ return $self->{_resultset}; >+ } >+ else { >+ return Koha::Database->new()->schema()->resultset( $self->type() ); >+ } > } > > =head3 type >diff --git a/t/db_dependent/Borrowers.t b/t/db_dependent/Borrowers.t >index 8d47ce7..bd75551 100755 >--- a/t/db_dependent/Borrowers.t >+++ b/t/db_dependent/Borrowers.t >@@ -66,13 +66,13 @@ my $b3 = Koha::Borrower->new( > ); > $b3->store(); > >-my $b1_new = Koha::Borrowers->new()->find( $b1->borrowernumber() ); >+my $b1_new = Koha::Borrowers->find( $b1->borrowernumber() ); > is( $b1->surname(), $b1_new->surname(), "Found matching borrower" ); > >-my @borrowers = Koha::Borrowers->new()->search( { branchcode => $branchcode } ); >+my @borrowers = Koha::Borrowers->search( { branchcode => $branchcode } ); > is( @borrowers, 3, "Found 3 borrowers with Search" ); > >-my $borrowers = Koha::Borrowers->new()->search( { branchcode => $branchcode } ); >+my $borrowers = Koha::Borrowers->search( { branchcode => $branchcode } ); > is( $borrowers->count( { branchcode => $branchcode } ), 3, "Counted 3 borrowers with Count" ); > > my $b = $borrowers->next(); >-- >1.7.2.5
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 13019
:
31964
|
32004
|
32007
|
32008
|
32009
|
32042
|
32043
|
32045
|
32056
|
32059
|
32065
|
32068
|
33418
|
33419
|
33420
|
33797
|
33840
|
33841
|
33842
|
33843
|
33844
|
33845
|
33846
|
33847
| 33848 |
33849
|
33850
|
33852
|
35813
|
35814
|
35815
|
35980