Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 4; |
22 |
use Test::More tests => 5; |
23 |
|
23 |
|
24 |
use Koha::Patron; |
24 |
use Koha::Patron; |
25 |
use Koha::Patrons; |
25 |
use Koha::Patrons; |
Lines 77-82
subtest 'guarantees' => sub {
Link Here
|
77 |
$_->delete for @guarantees; |
77 |
$_->delete for @guarantees; |
78 |
}; |
78 |
}; |
79 |
|
79 |
|
|
|
80 |
subtest 'siblings' => sub { |
81 |
plan tests => 7; |
82 |
my $siblings = $new_patron_1->siblings; |
83 |
is( ref($siblings), 'Koha::Patrons', 'Koha::Patron->siblings should not crashed if the patron has not guarantor' ); |
84 |
my $guarantee_1 = $builder->build( { source => 'Borrower', value => { guarantorid => $new_patron_1->borrowernumber } } ); |
85 |
my $retrieved_guarantee_1 = Koha::Patrons->find($guarantee_1); |
86 |
$siblings = $retrieved_guarantee_1->siblings; |
87 |
is( ref($siblings), 'Koha::Patrons', 'Koha::Patron->siblings should return a Koha::Patrons result set in a scalar context' ); |
88 |
my @siblings = $retrieved_guarantee_1->siblings; |
89 |
is( ref( \@siblings ), 'ARRAY', 'Koha::Patron->siblings should return an array in a list context' ); |
90 |
is( $siblings->count, 0, 'guarantee_1 should not have siblings yet' ); |
91 |
my $guarantee_2 = $builder->build( { source => 'Borrower', value => { guarantorid => $new_patron_1->borrowernumber } } ); |
92 |
my $guarantee_3 = $builder->build( { source => 'Borrower', value => { guarantorid => $new_patron_1->borrowernumber } } ); |
93 |
$siblings = $retrieved_guarantee_1->siblings; |
94 |
is( $siblings->count, 2, 'guarantee_1 should have 2 siblings' ); |
95 |
is( $guarantee_2->{borrowernumber}, $siblings->next->borrowernumber, 'guarantee_2 should exist in the guarantees' ); |
96 |
is( $guarantee_3->{borrowernumber}, $siblings->next->borrowernumber, 'guarantee_3 should exist in the guarantees' ); |
97 |
$_->delete for $retrieved_guarantee_1->siblings; |
98 |
$retrieved_guarantee_1->delete; |
99 |
}; |
80 |
|
100 |
|
81 |
$retrieved_patron_1->delete; |
101 |
$retrieved_patron_1->delete; |
82 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
102 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
83 |
- |
|
|