@@ -, +, @@ Koha::Patron::HouseboundProfile->housebound_visits return a resultset $ kshell k$ prove t/db_dependent/Patron/HouseboundProfiles.t --- Koha/Patron/HouseboundProfile.pm | 10 +- .../prog/en/modules/members/housebound.tt | 2 +- t/db_dependent/Patron/HouseboundProfiles.t | 96 ++++++++++--------- 3 files changed, 55 insertions(+), 53 deletions(-) --- a/Koha/Patron/HouseboundProfile.pm +++ a/Koha/Patron/HouseboundProfile.pm @@ -42,17 +42,17 @@ Standard Koha::Objects definitions, and additional methods. =head3 housebound_visits - my $visits = Koha::Patron::HouseboundProfile->housebound_visits; + my $visits = Koha::Patron::HouseboundProfile->housebound_visits; -Returns an arrayref of all visits associated this houseboundProfile. +Returns a I iterator for all the visits +associated this houseboundProfile. =cut sub housebound_visits { my ( $self ) = @_; - my @visits = Koha::Patron::HouseboundVisits - ->special_search({ borrowernumber => $self->borrowernumber })->as_list; - return \@visits; + return Koha::Patron::HouseboundVisits + ->special_search({ borrowernumber => $self->borrowernumber }); } =head3 _type --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt @@ -387,7 +387,7 @@

Deliveries

[% housebound_visits = housebound_profile.housebound_visits %] - [% IF housebound_visits.size > 0 %] + [% IF housebound_visits.count > 0 %] --- a/t/db_dependent/Patron/HouseboundProfiles.t +++ a/t/db_dependent/Patron/HouseboundProfiles.t @@ -17,58 +17,60 @@ use Modern::Perl; -use Test::More tests => 3; +use Test::More tests => 1; use Koha::Database; use Koha::Patron::HouseboundProfiles; use t::lib::TestBuilder; -my $schema = Koha::Database->new->schema; -$schema->storage->txn_begin; - +my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; -# Profile Tests - -my $profile = $builder->build({ source => 'HouseboundProfile' }); - -is( - Koha::Patron::HouseboundProfiles - ->find($profile->{borrowernumber})->borrowernumber, - $profile->{borrowernumber}, - "Find created profile." -); - -my @profiles = Koha::Patron::HouseboundProfiles - ->search({ day => $profile->{day} })->as_list; -my $found_profile = shift @profiles; -is( - $found_profile->borrowernumber, - $profile->{borrowernumber}, - "Search for created profile." -); - -# ->housebound_profile Tests - -my $visit1 = $builder->build({ - source => 'HouseboundVisit', - value => { - borrowernumber => $profile->{borrowernumber}, - }, -}); -my $visit2 = $builder->build({ - source => 'HouseboundVisit', - value => { - borrowernumber => $profile->{borrowernumber}, - }, -}); - -is( - scalar @{$found_profile->housebound_visits}, - 2, - "Fetch housebound_visits." -); - -$schema->storage->txn_rollback; - +subtest 'housebound_visits() tests' => sub { + + plan tests => 3; + + $schema->storage->txn_begin; + + my $profile = $builder->build({ source => 'HouseboundProfile' }); + + is( + Koha::Patron::HouseboundProfiles + ->find($profile->{borrowernumber})->borrowernumber, + $profile->{borrowernumber}, + "Find created profile." + ); + + my @profiles = Koha::Patron::HouseboundProfiles + ->search({ day => $profile->{day} })->as_list; + my $found_profile = shift @profiles; + is( + $found_profile->borrowernumber, + $profile->{borrowernumber}, + "Search for created profile." + ); + + # ->housebound_profile Tests + + my $visit1 = $builder->build({ + source => 'HouseboundVisit', + value => { + borrowernumber => $profile->{borrowernumber}, + }, + }); + my $visit2 = $builder->build({ + source => 'HouseboundVisit', + value => { + borrowernumber => $profile->{borrowernumber}, + }, + }); + + is( + $found_profile->housebound_visits->count, + 2, + "Fetch housebound_visits." + ); + + $schema->storage->txn_rollback; +}; --
IDDateChooserDelivererActions