Lines 52-65
subtest 'update' => sub {
Link Here
|
52 |
}; |
52 |
}; |
53 |
|
53 |
|
54 |
subtest 'search_related' => sub { |
54 |
subtest 'search_related' => sub { |
55 |
plan tests => 3; |
55 |
plan tests => 8; |
56 |
my $builder = t::lib::TestBuilder->new; |
56 |
my $builder = t::lib::TestBuilder->new; |
57 |
my $patron_1 = $builder->build( { source => 'Borrower' } ); |
57 |
my $patron_1 = $builder->build( { source => 'Borrower' } ); |
58 |
my $patron_2 = $builder->build( { source => 'Borrower' } ); |
58 |
my $patron_2 = $builder->build( { source => 'Borrower' } ); |
59 |
my $libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode'); |
59 |
my $libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode'); |
|
|
60 |
is( ref( $libraries ), 'Koha::Libraries', 'Koha::Objects->search_related should return an instanciated Koha::Objects-based object' ); |
60 |
is( $libraries->count, 2, 'Koha::Objects->search_related should work as expected' ); |
61 |
is( $libraries->count, 2, 'Koha::Objects->search_related should work as expected' ); |
61 |
is( $libraries->next->branchcode, $patron_1->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
62 |
is( $libraries->next->branchcode, $patron_1->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
62 |
is( $libraries->next->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
63 |
is( $libraries->next->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
|
|
64 |
|
65 |
my @libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode'); |
66 |
is( ref( $libraries[0] ), 'Koha::Library', 'Koha::Objects->search_related should return a list of Koha::Object-based objects' ); |
67 |
is( scalar(@libraries), 2, 'Koha::Objects->search_related should work as expected' ); |
68 |
is( $libraries[0]->branchcode, $patron_1->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
69 |
is( $libraries[1]->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
63 |
}; |
70 |
}; |
64 |
|
71 |
|
65 |
$schema->storage->txn_rollback; |
72 |
$schema->storage->txn_rollback; |
66 |
- |
|
|