View | Details | Raw Unified | Return to bug 18179
Collapse All | Expand All

(-)a/Koha/Objects.pm (+2 lines)
Lines 78-83 my $object = Koha::Objects->find( { keypart1 => $keypart1, keypart2 => $keypart2 Link Here
78
sub find {
78
sub find {
79
    my ( $self, $id ) = @_;
79
    my ( $self, $id ) = @_;
80
80
81
    croak 'Cannot use "->find" in list context' if wantarray;
82
81
    return unless defined($id);
83
    return unless defined($id);
82
84
83
    my $result = $self->_resultset()->find($id);
85
    my $result = $self->_resultset()->find($id);
(-)a/t/db_dependent/Koha/Objects.t (-2 / +11 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 13;
22
use Test::More tests => 14;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use Koha::Authority::Types;
25
use Koha::Authority::Types;
Lines 43-48 my @columns = Koha::Patrons->columns; Link Here
43
my $borrowernumber_exists = grep { /^borrowernumber$/ } @columns;
43
my $borrowernumber_exists = grep { /^borrowernumber$/ } @columns;
44
is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' );
44
is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' );
45
45
46
subtest 'find' => sub {
47
    plan tests => 2;
48
    my $patron = $builder->build({source => 'Borrower'});
49
    my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} );
50
    is( $patron_object->borrowernumber, $patron->{borrowernumber}, '->find should return the correct object' );
51
52
    eval { my @patrons = Koha::Patrons->find( $patron->{borrowernumber} ); };
53
    like( $@, qr|^Cannot use "->find" in list context|, "->find should not be called in list context to avoid side-effects" );
54
};
55
46
subtest 'update' => sub {
56
subtest 'update' => sub {
47
    plan tests => 2;
57
    plan tests => 2;
48
58
49
- 

Return to bug 18179