Lines 46-58
my $borrowernumber_exists = grep { /^borrowernumber$/ } @columns;
Link Here
|
46 |
is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' ); |
46 |
is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' ); |
47 |
|
47 |
|
48 |
subtest 'find' => sub { |
48 |
subtest 'find' => sub { |
49 |
plan tests => 4; |
49 |
plan tests => 6; |
50 |
my $patron = $builder->build({source => 'Borrower'}); |
50 |
my $patron = $builder->build({source => 'Borrower'}); |
51 |
my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); |
51 |
my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); |
52 |
is( $patron_object->borrowernumber, $patron->{borrowernumber}, '->find should return the correct object' ); |
52 |
is( $patron_object->borrowernumber, $patron->{borrowernumber}, '->find should return the correct object' ); |
53 |
|
53 |
|
54 |
eval { my @patrons = Koha::Patrons->find( $patron->{borrowernumber} ); }; |
54 |
my @patrons = Koha::Patrons->find( $patron->{borrowernumber} ); |
55 |
like( $@, qr|^Cannot use "->find" in list context|, "->find should not be called in list context to avoid side-effects" ); |
55 |
is(scalar @patrons, 1, '->find in list context returns a value'); |
|
|
56 |
is($patrons[0]->borrowernumber, $patron->{borrowernumber}, '->find in list context returns the same value as in scalar context'); |
57 |
|
58 |
my $patrons = { |
59 |
foo => Koha::Patrons->find('foo'), |
60 |
bar => 'baz', |
61 |
}; |
62 |
is ($patrons->{foo}, undef, '->find in list context returns undef when no record is found'); |
56 |
|
63 |
|
57 |
# Test sending undef to find; should not generate a warning |
64 |
# Test sending undef to find; should not generate a warning |
58 |
warning_is { $patron = Koha::Patrons->find( undef ); } |
65 |
warning_is { $patron = Koha::Patrons->find( undef ); } |
59 |
- |
|
|