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

(-)a/Koha/Objects.pm (-1 / +2 lines)
Lines 20-25 package Koha::Objects; Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Carp;
22
use Carp;
23
use List::MoreUtils qw( none );
23
24
24
use Koha::Database;
25
use Koha::Database;
25
26
Lines 86-92 sub find { Link Here
86
87
87
    croak 'Cannot use "->find" in list context' if wantarray;
88
    croak 'Cannot use "->find" in list context' if wantarray;
88
89
89
    return unless @pars;
90
    return if !@pars || none { defined($_) } @pars;
90
91
91
    my $result = $self->_resultset()->find( @pars );
92
    my $result = $self->_resultset()->find( @pars );
92
93
(-)a/t/db_dependent/Koha/Objects.t (-2 / +7 lines)
Lines 45-57 my $borrowernumber_exists = grep { /^borrowernumber$/ } @columns; Link Here
45
is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' );
45
is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' );
46
46
47
subtest 'find' => sub {
47
subtest 'find' => sub {
48
    plan tests => 2;
48
    plan tests => 4;
49
    my $patron = $builder->build({source => 'Borrower'});
49
    my $patron = $builder->build({source => 'Borrower'});
50
    my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} );
50
    my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} );
51
    is( $patron_object->borrowernumber, $patron->{borrowernumber}, '->find should return the correct object' );
51
    is( $patron_object->borrowernumber, $patron->{borrowernumber}, '->find should return the correct object' );
52
52
53
    eval { my @patrons = Koha::Patrons->find( $patron->{borrowernumber} ); };
53
    eval { my @patrons = Koha::Patrons->find( $patron->{borrowernumber} ); };
54
    like( $@, qr|^Cannot use "->find" in list context|, "->find should not be called in list context to avoid side-effects" );
54
    like( $@, qr|^Cannot use "->find" in list context|, "->find should not be called in list context to avoid side-effects" );
55
56
    # Test sending undef to find; should not generate a warning
57
    warning_is { $patron = Koha::Patrons->find( undef ); }
58
        "", "Sending undef does not trigger a DBIx warning";
59
    warning_is { $patron = Koha::Patrons->find( undef, undef ); }
60
        "", "Sending two undefs does not trigger a DBIx warning too";
55
};
61
};
56
62
57
subtest 'update' => sub {
63
subtest 'update' => sub {
58
- 

Return to bug 18361