Lines 99-114
subtest 'sms_provider' => sub {
Link Here
|
99 |
}; |
99 |
}; |
100 |
|
100 |
|
101 |
subtest 'guarantees' => sub { |
101 |
subtest 'guarantees' => sub { |
102 |
plan tests => 13; |
102 |
|
|
|
103 |
plan tests => 9; |
103 |
|
104 |
|
104 |
t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test|test2' ); |
105 |
t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test|test2' ); |
105 |
|
106 |
|
106 |
my $guarantees = $new_patron_1->guarantee_relationships; |
107 |
my $guarantees = $new_patron_1->guarantee_relationships; |
107 |
is( ref($guarantees), 'Koha::Patron::Relationships', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' ); |
108 |
is( ref($guarantees), 'Koha::Patron::Relationships', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' ); |
108 |
is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee relationships' ); |
109 |
is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee relationships' ); |
109 |
my @guarantees = $new_patron_1->guarantee_relationships; |
|
|
110 |
is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantee_relationships should return an array in a list context' ); |
111 |
is( scalar(@guarantees), 0, 'new_patron_1 should have 0 guarantee' ); |
112 |
|
110 |
|
113 |
my $guarantee_1 = $builder->build({ source => 'Borrower' }); |
111 |
my $guarantee_1 = $builder->build({ source => 'Borrower' }); |
114 |
my $relationship_1 = Koha::Patron::Relationship->new( { guarantor_id => $new_patron_1->id, guarantee_id => $guarantee_1->{borrowernumber}, relationship => 'test' } )->store(); |
112 |
my $relationship_1 = Koha::Patron::Relationship->new( { guarantor_id => $new_patron_1->id, guarantee_id => $guarantee_1->{borrowernumber}, relationship => 'test' } )->store(); |
Lines 118-127
subtest 'guarantees' => sub {
Link Here
|
118 |
$guarantees = $new_patron_1->guarantee_relationships; |
116 |
$guarantees = $new_patron_1->guarantee_relationships; |
119 |
is( ref($guarantees), 'Koha::Patron::Relationships', 'Koha::Patron->guarantee_relationships should return a Koha::Patrons result set in a scalar context' ); |
117 |
is( ref($guarantees), 'Koha::Patron::Relationships', 'Koha::Patron->guarantee_relationships should return a Koha::Patrons result set in a scalar context' ); |
120 |
is( $guarantees->count, 2, 'new_patron_1 should have 2 guarantees' ); |
118 |
is( $guarantees->count, 2, 'new_patron_1 should have 2 guarantees' ); |
121 |
@guarantees = $new_patron_1->guarantee_relationships; |
119 |
|
122 |
is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantee_relationships should return an array in a list context' ); |
120 |
$guarantees->delete; |
123 |
is( scalar(@guarantees), 2, 'new_patron_1 should have 2 guarantees' ); |
|
|
124 |
$_->delete for @guarantees; |
125 |
|
121 |
|
126 |
#Test return order of guarantees BZ 18635 |
122 |
#Test return order of guarantees BZ 18635 |
127 |
my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; |
123 |
my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; |
Lines 246-252
subtest 'category' => sub {
Link Here
|
246 |
}; |
242 |
}; |
247 |
|
243 |
|
248 |
subtest 'siblings' => sub { |
244 |
subtest 'siblings' => sub { |
249 |
plan tests => 7; |
245 |
|
|
|
246 |
plan tests => 6; |
247 |
|
250 |
my $siblings = $new_patron_1->siblings; |
248 |
my $siblings = $new_patron_1->siblings; |
251 |
is( $siblings, undef, 'Koha::Patron->siblings should not crashed if the patron has no guarantor' ); |
249 |
is( $siblings, undef, 'Koha::Patron->siblings should not crashed if the patron has no guarantor' ); |
252 |
my $guarantee_1 = $builder->build( { source => 'Borrower' } ); |
250 |
my $guarantee_1 = $builder->build( { source => 'Borrower' } ); |
Lines 254-261
subtest 'siblings' => sub {
Link Here
|
254 |
my $retrieved_guarantee_1 = Koha::Patrons->find($guarantee_1); |
252 |
my $retrieved_guarantee_1 = Koha::Patrons->find($guarantee_1); |
255 |
$siblings = $retrieved_guarantee_1->siblings; |
253 |
$siblings = $retrieved_guarantee_1->siblings; |
256 |
is( ref($siblings), 'Koha::Patrons', 'Koha::Patron->siblings should return a Koha::Patrons result set in a scalar context' ); |
254 |
is( ref($siblings), 'Koha::Patrons', 'Koha::Patron->siblings should return a Koha::Patrons result set in a scalar context' ); |
257 |
my @siblings = $retrieved_guarantee_1->siblings; |
|
|
258 |
is( ref( \@siblings ), 'ARRAY', 'Koha::Patron->siblings should return an array in a list context' ); |
259 |
is( $siblings->count, 0, 'guarantee_1 should not have siblings yet' ); |
255 |
is( $siblings->count, 0, 'guarantee_1 should not have siblings yet' ); |
260 |
my $guarantee_2 = $builder->build( { source => 'Borrower' } ); |
256 |
my $guarantee_2 = $builder->build( { source => 'Borrower' } ); |
261 |
my $relationship_2 = Koha::Patron::Relationship->new( { guarantor_id => $new_patron_1->borrowernumber, guarantee_id => $guarantee_2->{borrowernumber}, relationship => 'test' } )->store(); |
257 |
my $relationship_2 = Koha::Patron::Relationship->new( { guarantor_id => $new_patron_1->borrowernumber, guarantee_id => $guarantee_2->{borrowernumber}, relationship => 'test' } )->store(); |
262 |
- |
|
|