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> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
6f0316a8d2
commit
3107975ba9
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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" );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue