|
Lines 82-95
subtest 'not_covered_yet' => sub {
Link Here
|
| 82 |
}; |
82 |
}; |
| 83 |
|
83 |
|
| 84 |
subtest 'search_related' => sub { |
84 |
subtest 'search_related' => sub { |
| 85 |
plan tests => 3; |
85 |
plan tests => 8; |
| 86 |
my $builder = t::lib::TestBuilder->new; |
86 |
my $builder = t::lib::TestBuilder->new; |
| 87 |
my $patron_1 = $builder->build( { source => 'Borrower' } ); |
87 |
my $patron_1 = $builder->build( { source => 'Borrower' } ); |
| 88 |
my $patron_2 = $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'); |
89 |
my $libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode'); |
|
|
90 |
is( ref( $libraries ), 'Koha::Libraries', 'Koha::Objects->search_related should return an instanciated Koha::Objects-based object' ); |
| 90 |
is( $libraries->count, 2, 'Koha::Objects->search_related should work as expected' ); |
91 |
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_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 |
is( $libraries->next->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
|
|
94 |
|
| 95 |
my @libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode'); |
| 96 |
is( ref( $libraries[0] ), 'Koha::Library', 'Koha::Objects->search_related should return a list of Koha::Object-based objects' ); |
| 97 |
is( scalar(@libraries), 2, 'Koha::Objects->search_related should work as expected' ); |
| 98 |
is( $libraries[0]->branchcode, $patron_1->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
| 99 |
is( $libraries[1]->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
| 93 |
}; |
100 |
}; |
| 94 |
|
101 |
|
| 95 |
$schema->storage->txn_rollback; |
102 |
$schema->storage->txn_rollback; |
| 96 |
- |
|
|