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

(-)a/Koha/Patron/HouseboundProfile.pm (-5 / +5 lines)
Lines 42-58 Standard Koha::Objects definitions, and additional methods. Link Here
42
42
43
=head3 housebound_visits
43
=head3 housebound_visits
44
44
45
  my $visits = Koha::Patron::HouseboundProfile->housebound_visits;
45
    my $visits = Koha::Patron::HouseboundProfile->housebound_visits;
46
46
47
Returns an arrayref of all visits associated this houseboundProfile.
47
Returns a I<Koha::Patron::HouseboundVisits> iterator for all the visits
48
associated this houseboundProfile.
48
49
49
=cut
50
=cut
50
51
51
sub housebound_visits {
52
sub housebound_visits {
52
    my ( $self ) = @_;
53
    my ( $self ) = @_;
53
    my @visits = Koha::Patron::HouseboundVisits
54
    return Koha::Patron::HouseboundVisits
54
        ->special_search({ borrowernumber => $self->borrowernumber })->as_list;
55
        ->special_search({ borrowernumber => $self->borrowernumber });
55
    return \@visits;
56
}
56
}
57
57
58
=head3 _type
58
=head3 _type
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt (-1 / +1 lines)
Lines 387-393 Link Here
387
              <div>
387
              <div>
388
                <h3>Deliveries</h3>
388
                <h3>Deliveries</h3>
389
                [% housebound_visits = housebound_profile.housebound_visits %]
389
                [% housebound_visits = housebound_profile.housebound_visits %]
390
                [% IF  housebound_visits.size > 0 %]
390
                [% IF  housebound_visits.count > 0 %]
391
                <table border="0" width="100%" cellpadding="3" cellspacing="0">
391
                <table border="0" width="100%" cellpadding="3" cellspacing="0">
392
                  <tr>
392
                  <tr>
393
                    <th>ID</th><th>Date</th><th>Chooser</th><th>Deliverer</th><th class="noExport">Actions</th>
393
                    <th>ID</th><th>Date</th><th>Chooser</th><th>Deliverer</th><th class="noExport">Actions</th>
(-)a/t/db_dependent/Patron/HouseboundProfiles.t (-48 / +49 lines)
Lines 17-74 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 3;
20
use Test::More tests => 1;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Patron::HouseboundProfiles;
23
use Koha::Patron::HouseboundProfiles;
24
24
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
26
27
my $schema = Koha::Database->new->schema;
27
my $schema  = Koha::Database->new->schema;
28
$schema->storage->txn_begin;
29
30
my $builder = t::lib::TestBuilder->new;
28
my $builder = t::lib::TestBuilder->new;
31
29
32
# Profile Tests
30
subtest 'housebound_visits() tests' => sub {
33
31
34
my $profile = $builder->build({ source => 'HouseboundProfile' });
32
    plan tests => 3;
35
33
36
is(
34
    $schema->storage->txn_begin;
37
    Koha::Patron::HouseboundProfiles
35
38
          ->find($profile->{borrowernumber})->borrowernumber,
36
    my $profile = $builder->build({ source => 'HouseboundProfile' });
39
    $profile->{borrowernumber},
37
40
    "Find created profile."
38
    is(
41
);
39
        Koha::Patron::HouseboundProfiles
42
40
            ->find($profile->{borrowernumber})->borrowernumber,
43
my @profiles = Koha::Patron::HouseboundProfiles
41
        $profile->{borrowernumber},
44
    ->search({ day => $profile->{day} })->as_list;
42
        "Find created profile."
45
my $found_profile = shift @profiles;
43
    );
46
is(
44
47
    $found_profile->borrowernumber,
45
    my @profiles = Koha::Patron::HouseboundProfiles
48
    $profile->{borrowernumber},
46
        ->search({ day => $profile->{day} })->as_list;
49
    "Search for created profile."
47
    my $found_profile = shift @profiles;
50
);
48
    is(
51
49
        $found_profile->borrowernumber,
52
# ->housebound_profile Tests
50
        $profile->{borrowernumber},
53
51
        "Search for created profile."
54
my $visit1 = $builder->build({
52
    );
55
    source => 'HouseboundVisit',
53
56
    value  => {
54
    # ->housebound_profile Tests
57
        borrowernumber => $profile->{borrowernumber},
55
58
    },
56
    my $visit1 = $builder->build({
59
});
57
        source => 'HouseboundVisit',
60
my $visit2 = $builder->build({
58
        value  => {
61
    source => 'HouseboundVisit',
59
            borrowernumber => $profile->{borrowernumber},
62
    value  => {
60
        },
63
        borrowernumber => $profile->{borrowernumber},
61
    });
64
    },
62
    my $visit2 = $builder->build({
65
});
63
        source => 'HouseboundVisit',
66
64
        value  => {
67
is(
65
            borrowernumber => $profile->{borrowernumber},
68
    scalar @{$found_profile->housebound_visits},
66
        },
69
    2,
67
    });
70
    "Fetch housebound_visits."
68
71
);
69
    is(
72
70
        $found_profile->housebound_visits->count,
73
$schema->storage->txn_rollback;
71
        2,
74
72
        "Fetch housebound_visits."
73
    );
74
75
    $schema->storage->txn_rollback;
76
};
75
- 

Return to bug 29847