|
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 |
- |
|
|