Bugzilla – Attachment 33847 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: (follow-up) Remove smartmatch operator
SIGNED-OFF-Bug-13019-follow-up-Remove-smartmatch-o.patch (text/plain), 4.24 KB, created by
Kyle M Hall (khall)
on 2014-11-24 12:58:26 UTC
(
hide
)
Description:
Bug 13019: (follow-up) Remove smartmatch operator
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2014-11-24 12:58:26 UTC
Size:
4.24 KB
patch
obsolete
>From 9c24ab1368632ed550c3af677060792d64cbe456 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 10 Nov 2014 12:55:35 +0100 >Subject: [PATCH] [SIGNED-OFF] Bug 13019: (follow-up) Remove smartmatch operator > >This patch also adds 1 test. > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Object.pm | 6 ++++-- > Koha/Objects.pm | 12 ++++++------ > t/db_dependent/Borrower.t | 14 +++++++++----- > 3 files changed, 19 insertions(+), 13 deletions(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index d1e0455..0093ed1 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -48,6 +48,8 @@ This class must always be subclassed. > my $object = Koha::Object->new(); > my $object = Koha::Object->new($attributes); > >+Note that this cannot be used to retrieve record from the DB. >+ > =cut > > sub new { >@@ -183,7 +185,7 @@ sub set { > my @columns = @{$self->_columns()}; > > foreach my $p ( keys %$properties ) { >- unless ( $p ~~ @columns ) { >+ unless ( grep {/^$p$/} @columns ) { > carp("No property $p!"); > return 0; > } >@@ -252,7 +254,7 @@ sub AUTOLOAD { > > my @columns = @{$self->_columns()}; > # Using direct setter/getter like $item->barcode() or $item->barcode($barcode); >- if ( $method ~~ @columns ) { >+ if ( grep {/^$method$/} @columns ) { > if ( @_ ) { > return $self->_result()->set_column( $method, @_ ); > } else { >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 1eaf2be..8c17665 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -48,7 +48,7 @@ This class must be subclassed. > > =head3 Koha::Objects->new(); > >-my $object = Koha::Object->new(); >+my $object = Koha::Objects->new(); > > =cut > >@@ -61,7 +61,7 @@ sub new { > > =head3 Koha::Objects->new_from_dbic(); > >-my $object = Koha::Object->new_from_dbic( $resultset ); >+my $object = Koha::Objects->new_from_dbic( $resultset ); > > =cut > >@@ -74,8 +74,8 @@ sub new_from_dbic { > > =head3 Koha::Objects->find(); > >-my $object = Koha::Object->find($id); >-my $object = Koha::Object->find( { keypart1 => $keypart1, keypart2 => $keypart2 } ); >+my $object = Koha::Objects->find($id); >+my $object = Koha::Objects->find( { keypart1 => $keypart1, keypart2 => $keypart2 } ); > > =cut > >@@ -91,7 +91,7 @@ sub find { > > =head3 Koha::Objects->search(); > >-my @objects = Koha::Object->search($params); >+my @objects = Koha::Objects->search($params); > > =cut > >@@ -114,7 +114,7 @@ sub search { > > =head3 Koha::Objects->count(); > >-my @objects = Koha::Object->count($params); >+my @objects = Koha::Objects->count($params); > > =cut > >diff --git a/t/db_dependent/Borrower.t b/t/db_dependent/Borrower.t >index 620b6ff..8290cab 100755 >--- a/t/db_dependent/Borrower.t >+++ b/t/db_dependent/Borrower.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 12; >+use Test::More tests => 13; > use Test::Warn; > > use C4::Context; >@@ -45,12 +45,16 @@ $object->branchcode( $branchcode ); > $object->surname("Test Surname"); > $object->store(); > >-my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $object->borrowernumber() ); >-is( $borrower->surname(), "Test Surname", "Object found in database" ); >- > is( $object->in_storage, 1, "Object is now stored" ); > >+my $borrowernumber = $object->borrowernumber; >+ >+my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber ); >+is( $borrower->surname(), "Test Surname", "Object found in database" ); >+ > is( $object->is_changed(), 0, "Object is unchanged" ); >+$object->surname("Test Surname"); >+is( $object->is_changed(), 0, "Object is still unchanged" ); > $object->surname("Test Surname 2"); > is( $object->is_changed(), 1, "Object is changed" ); > >@@ -63,7 +67,7 @@ $object->store(); > is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" ); > > $object->delete(); >-$borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $object->borrowernumber() ); >+$borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber ); > ok( ! $borrower, "Object no longer found in database" ); > is( $object->in_storage, 0, "Object is not in storage" ); > >-- >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