Bugzilla – Attachment 33417 Details for
Bug 10363
Move authorised value related code into its own package
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13019: (follow-up) Remove smartmatch operator
Bug-13019-follow-up-Remove-smartmatch-operator.patch (text/plain), 4.16 KB, created by
Jonathan Druart
on 2014-11-10 13:15:58 UTC
(
hide
)
Description:
Bug 13019: (follow-up) Remove smartmatch operator
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-11-10 13:15:58 UTC
Size:
4.16 KB
patch
obsolete
>From f6620281fb4ed34979fe0421beab6b87afb1080a 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] Bug 13019: (follow-up) Remove smartmatch operator > >This patch also adds 1 test. > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> > >http://bugs.koha-community.org/show_bug.cgi?id=10363 >--- > 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" ); > >-- >2.1.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 10363
:
18430
|
18431
|
18432
|
18751
|
18752
|
18753
|
20729
|
21833
|
21834
|
21835
|
21836
|
25284
|
25285
|
25286
|
25287
|
30583
|
30584
|
30585
|
30710
|
30711
|
30712
|
31565
|
32632
|
32633
|
32634
|
33416
|
33417
|
33422
|
33423
|
33860
|
33861
|
33862
|
33889
|
33949
|
35838
|
35839
|
35840
|
35841
|
41290
|
41291
|
41292
|
41293
|
41294
|
41302
|
41343
|
41344
|
41345
|
43112
|
43113
|
43114
|
43550
|
43551
|
43552
|
43553
|
43554
|
43555
|
43556
|
43557
|
43558
|
43559
|
43696
|
43827