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

(-)a/Koha/Objects.pm (+13 lines)
Lines 130-135 sub search { Link Here
130
    }
130
    }
131
}
131
}
132
132
133
=head3 search_related
134
135
    my @objects = Koha::Objects->search_related( $rel_name, $cond?, \%attrs? );
136
137
Searches the specified relationship, optionally specifying a condition and attributes for matching records.
138
139
=cut
140
141
sub search_related {
142
    my ( $self, @params ) = @_;
143
    return $self->_resultset->search_related( @params );
144
}
145
133
=head3 Koha::Objects->next();
146
=head3 Koha::Objects->next();
134
147
135
my $object = Koha::Objects->next();
148
my $object = Koha::Objects->next();
(-)a/t/db_dependent/Koha/Objects.t (-2 / +12 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 7;
22
use Test::More tests => 8;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use Koha::Authority::Types;
25
use Koha::Authority::Types;
Lines 81-85 subtest 'not_covered_yet' => sub { Link Here
81
    warning_is { Koha::Patrons->search->not_covered_yet } { carped => 'The method not_covered_yet is not covered by tests' }, "If a method is not covered by tests, the AUTOLOAD method won't execute the method";
81
    warning_is { Koha::Patrons->search->not_covered_yet } { carped => 'The method not_covered_yet is not covered by tests' }, "If a method is not covered by tests, the AUTOLOAD method won't execute the method";
82
};
82
};
83
83
84
subtest 'search_related' => sub {
85
    plan tests => 3;
86
    my $builder   = t::lib::TestBuilder->new;
87
    my $patron_1  = $builder->build( { source => 'Borrower' } );
88
    my $patron_2  = $builder->build( { source => 'Borrower' } );
89
    my $libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode');
90
    is( $libraries->count,            2,                       'Koha::Objects->search_related should work as expected' );
91
    is( $libraries->next->branchcode, $patron_1->{branchcode}, 'Koha::Objects->search_related should work as expected' );
92
    is( $libraries->next->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' );
93
};
94
84
$schema->storage->txn_rollback;
95
$schema->storage->txn_rollback;
85
1;
96
1;
86
- 

Return to bug 16965