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

(-)a/Koha/Account.pm (-4 / +2 lines)
Lines 647-654 my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_debits; Link Here
647
647
648
It returns the debit lines with outstanding amounts for the patron.
648
It returns the debit lines with outstanding amounts for the patron.
649
649
650
In scalar context, it returns a Koha::Account::Lines iterator. In list context, it will
650
It returns a Koha::Account::Lines iterator.
651
return a list of Koha::Account::Line objects.
652
651
653
=cut
652
=cut
654
653
Lines 669-676 my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_credits Link Here
669
668
670
It returns the credit lines with outstanding amounts for the patron.
669
It returns the credit lines with outstanding amounts for the patron.
671
670
672
In scalar context, it returns a Koha::Account::Lines iterator. In list context, it will
671
It returns a Koha::Account::Lines iterator.
673
return a list of Koha::Account::Line objects.
674
672
675
=cut
673
=cut
676
674
(-)a/Koha/Account/Line.pm (-1 / +1 lines)
Lines 285-291 sub void { Link Here
285
    # Find any applied offsets for the credit so we may reverse them
285
    # Find any applied offsets for the credit so we may reverse them
286
    my @account_offsets =
286
    my @account_offsets =
287
      Koha::Account::Offsets->search(
287
      Koha::Account::Offsets->search(
288
        { credit_id => $self->id, amount => { '<' => 0 }  } );
288
        { credit_id => $self->id, amount => { '<' => 0 }  } )->as_list;
289
289
290
    my $void;
290
    my $void;
291
    $self->_result->result_source->schema->txn_do(
291
    $self->_result->result_source->schema->txn_do(
(-)a/Koha/Acquisition/Currency.pm (-1 / +1 lines)
Lines 47-53 sub store { Link Here
47
                    currency => { '!=' => $self->currency },
47
                    currency => { '!=' => $self->currency },
48
                    active => 1,
48
                    active => 1,
49
                }
49
                }
50
            );
50
            )->as_list;
51
            for my $currency ( @currencies ) {
51
            for my $currency ( @currencies ) {
52
                $currency->active(0);
52
                $currency->active(0);
53
                $currency->store;
53
                $currency->store;
(-)a/Koha/Holds.pm (-2 / +2 lines)
Lines 124-130 sub get_items_that_can_fill { Link Here
124
              columns => ['itemnumber'],
124
              columns => ['itemnumber'],
125
              collapse => 1,
125
              collapse => 1,
126
          }
126
          }
127
      );
127
      )->as_list;
128
    my @waiting_holds = map { $_->itemnumber }
128
    my @waiting_holds = map { $_->itemnumber }
129
      Koha::Holds->search(
129
      Koha::Holds->search(
130
          { 'found' => 'W' },
130
          { 'found' => 'W' },
Lines 132-138 sub get_items_that_can_fill { Link Here
132
              columns => ['itemnumber'],
132
              columns => ['itemnumber'],
133
              collapse => 1,
133
              collapse => 1,
134
          }
134
          }
135
      );
135
      )->as_list;
136
136
137
    return Koha::Items->search(
137
    return Koha::Items->search(
138
        {
138
        {
(-)a/Koha/Patron.pm (-16 / +8 lines)
Lines 518-527 sub relationships_debt { Link Here
518
        Koha::Exceptions::BadParameter->throw( { parameter => 'only_this_guarantor' } ) unless @guarantors;
518
        Koha::Exceptions::BadParameter->throw( { parameter => 'only_this_guarantor' } ) unless @guarantors;
519
    } elsif ( $self->guarantor_relationships->count ) {
519
    } elsif ( $self->guarantor_relationships->count ) {
520
        # I am a guarantee, just get all my guarantors
520
        # I am a guarantee, just get all my guarantors
521
        @guarantors = $self->guarantor_relationships->guarantors;
521
        @guarantors = $self->guarantor_relationships->guarantors->as_list;
522
    } else {
522
    } else {
523
        # I am a guarantor, I need to get all the guarantors of all my guarantees
523
        # I am a guarantor, I need to get all the guarantors of all my guarantees
524
        @guarantors = map { $_->guarantor_relationships->guarantors } $self->guarantee_relationships->guarantees;
524
        @guarantors = map { $_->guarantor_relationships->guarantors->as_list } $self->guarantee_relationships->guarantees->as_list;
525
    }
525
    }
526
526
527
    my $non_issues_charges = 0;
527
    my $non_issues_charges = 0;
Lines 530-536 sub relationships_debt { Link Here
530
        $non_issues_charges += $guarantor->account->non_issues_charges if $include_guarantors && !$seen->{ $guarantor->id };
530
        $non_issues_charges += $guarantor->account->non_issues_charges if $include_guarantors && !$seen->{ $guarantor->id };
531
531
532
        # We've added what the guarantor owes, not added in that guarantor's guarantees as well
532
        # We've added what the guarantor owes, not added in that guarantor's guarantees as well
533
        my @guarantees = map { $_->guarantee } $guarantor->guarantee_relationships();
533
        my @guarantees = map { $_->guarantee } $guarantor->guarantee_relationships->as_list;
534
        my $guarantees_non_issues_charges = 0;
534
        my $guarantees_non_issues_charges = 0;
535
        foreach my $guarantee (@guarantees) {
535
        foreach my $guarantee (@guarantees) {
536
            next if $seen->{ $guarantee->id };
536
            next if $seen->{ $guarantee->id };
Lines 583-594 Returns the siblings of this patron. Link Here
583
sub siblings {
583
sub siblings {
584
    my ($self) = @_;
584
    my ($self) = @_;
585
585
586
    my @guarantors = $self->guarantor_relationships()->guarantors();
586
    my @guarantors = $self->guarantor_relationships()->guarantors()->as_list;
587
587
588
    return unless @guarantors;
588
    return unless @guarantors;
589
589
590
    my @siblings =
590
    my @siblings =
591
      map { $_->guarantee_relationships()->guarantees() } @guarantors;
591
      map { $_->guarantee_relationships()->guarantees()->as_list } @guarantors;
592
592
593
    return unless @siblings;
593
    return unless @siblings;
594
594
Lines 596-602 sub siblings { Link Here
596
    @siblings =
596
    @siblings =
597
      grep { !$seen{ $_->id }++ && ( $_->id != $self->id ) } @siblings;
597
      grep { !$seen{ $_->id }++ && ( $_->id != $self->id ) } @siblings;
598
598
599
    return wantarray ? @siblings : Koha::Patrons->search( { borrowernumber => { -in => [ map { $_->id } @siblings ] } } );
599
    return Koha::Patrons->search( { borrowernumber => { -in => [ map { $_->id } @siblings ] } } );
600
}
600
}
601
601
602
=head3 merge_with
602
=head3 merge_with
Lines 1357-1367 sub first_valid_email_address { Link Here
1357
sub get_club_enrollments {
1357
sub get_club_enrollments {
1358
    my ( $self, $return_scalar ) = @_;
1358
    my ( $self, $return_scalar ) = @_;
1359
1359
1360
    my $e = Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } );
1360
    return Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } );
1361
1362
    return $e if $return_scalar;
1363
1364
    return wantarray ? $e->as_list : $e;
1365
}
1361
}
1366
1362
1367
=head3 get_enrollable_clubs
1363
=head3 get_enrollable_clubs
Lines 1378-1388 sub get_enrollable_clubs { Link Here
1378
1374
1379
    $params->{borrower} = $self;
1375
    $params->{borrower} = $self;
1380
1376
1381
    my $e = Koha::Clubs->get_enrollable($params);
1377
    return Koha::Clubs->get_enrollable($params);
1382
1383
    return $e if $return_scalar;
1384
1385
    return wantarray ? $e->as_list : $e;
1386
}
1378
}
1387
1379
1388
=head3 account_locked
1380
=head3 account_locked
(-)a/Koha/Patron/Attributes.pm (-1 / +1 lines)
Lines 97-103 sub merge_and_replace_with { Link Here
97
    my ( $self, $new_attributes ) = @_;
97
    my ( $self, $new_attributes ) = @_;
98
98
99
    my @existing_attributes = @{$self->unblessed};
99
    my @existing_attributes = @{$self->unblessed};
100
    my $attribute_types = { map { $_->code => $_->unblessed } Koha::Patron::Attribute::Types->search };
100
    my $attribute_types = { map { $_->code => $_->unblessed } Koha::Patron::Attribute::Types->search->as_list };
101
    my @new_attributes;
101
    my @new_attributes;
102
    for my $attr ( @$new_attributes ) {
102
    for my $attr ( @$new_attributes ) {
103
103
(-)a/Koha/Patron/Relationships.pm (-6 / +2 lines)
Lines 52-60 sub guarantors { Link Here
52
    @guarantor_ids = grep { defined $_ } @guarantor_ids;
52
    @guarantor_ids = grep { defined $_ } @guarantor_ids;
53
    @guarantor_ids = uniq( @guarantor_ids );
53
    @guarantor_ids = uniq( @guarantor_ids );
54
54
55
    my $guarantors = Koha::Patrons->search( { borrowernumber => \@guarantor_ids } );
55
    return Koha::Patrons->search( { borrowernumber => \@guarantor_ids } );
56
57
    return wantarray ? $guarantors->as_list : $guarantors;
58
}
56
}
59
57
60
=head3 guarantees
58
=head3 guarantees
Lines 71-84 sub guarantees { Link Here
71
69
72
    my @guarantee_ids = uniq( $rs->get_column('guarantee_id')->all() );
70
    my @guarantee_ids = uniq( $rs->get_column('guarantee_id')->all() );
73
71
74
    my $guarantees = Koha::Patrons->search(
72
    return Koha::Patrons->search(
75
        { borrowernumber => \@guarantee_ids },
73
        { borrowernumber => \@guarantee_ids },
76
        {
74
        {
77
            order_by => { -asc => [ 'surname', 'firstname' ] }
75
            order_by => { -asc => [ 'surname', 'firstname' ] }
78
        },
76
        },
79
    );
77
    );
80
81
    return wantarray ? $guarantees->as_list : $guarantees;
82
}
78
}
83
79
84
=head3 type
80
=head3 type
(-)a/Koha/SearchEngine/Elasticsearch.pm (-1 / +1 lines)
Lines 547-553 sub marc_records_to_documents { Link Here
547
547
548
    my %auth_match_headings;
548
    my %auth_match_headings;
549
    if( $self->index eq 'authorities' ){
549
    if( $self->index eq 'authorities' ){
550
        my @auth_types = Koha::Authority::Types->search();
550
        my @auth_types = Koha::Authority::Types->search->as_list;
551
        %auth_match_headings = map { $_->authtypecode => $_->auth_tag_to_report } @auth_types;
551
        %auth_match_headings = map { $_->authtypecode => $_->auth_tag_to_report } @auth_types;
552
    }
552
    }
553
553
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-3 / +3 lines)
Lines 456-465 sub _convert_facets { Link Here
456
456
457
    # We also have some special cases, e.g. itypes that need to show the
457
    # We also have some special cases, e.g. itypes that need to show the
458
    # value rather than the code.
458
    # value rather than the code.
459
    my @itypes = Koha::ItemTypes->search;
459
    my @itypes = Koha::ItemTypes->search->as_list;
460
    my @libraries = Koha::Libraries->search;
460
    my @libraries = Koha::Libraries->search->as_list;
461
    my $library_names = { map { $_->branchcode => $_->branchname } @libraries };
461
    my $library_names = { map { $_->branchcode => $_->branchname } @libraries };
462
    my @locations = Koha::AuthorisedValues->search( { category => 'LOC' } );
462
    my @locations = Koha::AuthorisedValues->search( { category => 'LOC' } )->as_list;
463
    my $opac = C4::Context->interface eq 'opac' ;
463
    my $opac = C4::Context->interface eq 'opac' ;
464
    my %special = (
464
    my %special = (
465
        itype    => { map { $_->itemtype         => $_->description } @itypes },
465
        itype    => { map { $_->itemtype         => $_->description } @itypes },
(-)a/t/db_dependent/Koha/Account.t (-21 / +2 lines)
Lines 56-62 subtest 'new' => sub { Link Here
56
56
57
subtest 'outstanding_debits() tests' => sub {
57
subtest 'outstanding_debits() tests' => sub {
58
58
59
    plan tests => 22;
59
    plan tests => 10;
60
60
61
    $schema->storage->txn_begin;
61
    $schema->storage->txn_begin;
62
62
Lines 70-88 subtest 'outstanding_debits() tests' => sub { Link Here
70
    push @generated_lines, $account->add_debit({ amount => 4, interface => 'commandline', type => 'OVERDUE' });
70
    push @generated_lines, $account->add_debit({ amount => 4, interface => 'commandline', type => 'OVERDUE' });
71
71
72
    my $lines     = $account->outstanding_debits();
72
    my $lines     = $account->outstanding_debits();
73
    my @lines_arr = $account->outstanding_debits();
74
73
75
    is( ref($lines), 'Koha::Account::Lines', 'Called in scalar context, outstanding_debits returns a Koha::Account::Lines object' );
74
    is( ref($lines), 'Koha::Account::Lines', 'Called in scalar context, outstanding_debits returns a Koha::Account::Lines object' );
76
    is( $lines->total_outstanding, 10, 'Outstandig debits total is correctly calculated' );
75
    is( $lines->total_outstanding, 10, 'Outstandig debits total is correctly calculated' );
77
76
78
    my $i = 0;
79
    foreach my $line ( @{ $lines->as_list } ) {
80
        my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id );
81
        is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" );
82
        is_deeply( $lines_arr[$i]->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" );
83
        is( ref($lines_arr[$i]), 'Koha::Account::Line', 'outstanding_debits returns a list of Koha::Account::Line objects in list context' );
84
        $i++;
85
    }
86
    my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' });
77
    my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' });
87
    Koha::Account::Line->new(
78
    Koha::Account::Line->new(
88
        {
79
        {
Lines 149-155 subtest 'outstanding_debits() tests' => sub { Link Here
149
140
150
subtest 'outstanding_credits() tests' => sub {
141
subtest 'outstanding_credits() tests' => sub {
151
142
152
    plan tests => 17;
143
    plan tests => 5;
153
144
154
    $schema->storage->txn_begin;
145
    $schema->storage->txn_begin;
155
146
Lines 163-182 subtest 'outstanding_credits() tests' => sub { Link Here
163
    push @generated_lines, $account->add_credit({ amount => 4, interface => 'commandline' });
154
    push @generated_lines, $account->add_credit({ amount => 4, interface => 'commandline' });
164
155
165
    my $lines     = $account->outstanding_credits();
156
    my $lines     = $account->outstanding_credits();
166
    my @lines_arr = $account->outstanding_credits();
167
157
168
    is( ref($lines), 'Koha::Account::Lines', 'Called in scalar context, outstanding_credits returns a Koha::Account::Lines object' );
158
    is( ref($lines), 'Koha::Account::Lines', 'Called in scalar context, outstanding_credits returns a Koha::Account::Lines object' );
169
    is( $lines->total_outstanding, -10, 'Outstandig credits total is correctly calculated' );
159
    is( $lines->total_outstanding, -10, 'Outstandig credits total is correctly calculated' );
170
160
171
    my $i = 0;
172
    foreach my $line ( @{ $lines->as_list } ) {
173
        my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id );
174
        is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" );
175
        is_deeply( $lines_arr[$i]->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" );
176
        is( ref($lines_arr[$i]), 'Koha::Account::Line', 'outstanding_debits returns a list of Koha::Account::Line objects in list context' );
177
        $i++;
178
    }
179
180
    my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' });
161
    my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' });
181
    $account  = $patron_2->account;
162
    $account  = $patron_2->account;
182
    $lines       = $account->outstanding_credits();
163
    $lines       = $account->outstanding_credits();
(-)a/t/db_dependent/Koha/Acquisition/Booksellers.t (-2 / +3 lines)
Lines 129-136 subtest '->subscriptions() tests' => sub { Link Here
129
129
130
    # Re-fetch vendor
130
    # Re-fetch vendor
131
    $vendor = Koha::Acquisition::Booksellers->find( $vendor->id );
131
    $vendor = Koha::Acquisition::Booksellers->find( $vendor->id );
132
    is( $vendor->subscriptions->count, 2, 'Vendor has two subscriptions' );
132
    my $subscriptions = $vendor->subscriptions;
133
    foreach my $subscription ( $vendor->subscriptions ) {
133
    is( $subscriptions->count, 2, 'Vendor has two subscriptions' );
134
    while (my $subscription = $subscriptions->next ) {
134
        is( ref($subscription), 'Koha::Subscription', 'Type is correct' );
135
        is( ref($subscription), 'Koha::Subscription', 'Type is correct' );
135
    }
136
    }
136
137
(-)a/t/db_dependent/Koha/Biblio.t (-4 / +1 lines)
Lines 126-132 subtest 'hidden_in_opac() tests' => sub { Link Here
126
126
127
subtest 'items() tests' => sub {
127
subtest 'items() tests' => sub {
128
128
129
    plan tests => 4;
129
    plan tests => 3;
130
130
131
    $schema->storage->txn_begin;
131
    $schema->storage->txn_begin;
132
132
Lines 141-149 subtest 'items() tests' => sub { Link Here
141
    is( ref($items), 'Koha::Items', 'Returns a Koha::Items resultset' );
141
    is( ref($items), 'Koha::Items', 'Returns a Koha::Items resultset' );
142
    is( $items->count, 2, 'Two items in resultset' );
142
    is( $items->count, 2, 'Two items in resultset' );
143
143
144
    my @items = $biblio->items->as_list;
145
    is( scalar @items, 2, 'Same result, but in list context' );
146
147
    $schema->storage->txn_rollback;
144
    $schema->storage->txn_rollback;
148
145
149
};
146
};
(-)a/t/db_dependent/Koha/Libraries.t (-2 / +2 lines)
Lines 300-306 subtest 'get_hold_libraries and validate_hold_sibling' => sub { Link Here
300
    my @hold_libraries_1 = ($library1, $library2);
300
    my @hold_libraries_1 = ($library1, $library2);
301
    my @hold_libraries_2 = ($library3, $library4, $library5);
301
    my @hold_libraries_2 = ($library3, $library4, $library5);
302
302
303
    my @result = $library1->get_hold_libraries();
303
    my @result = $library1->get_hold_libraries()->as_list;
304
    # library1 and library2 are siblings
304
    # library1 and library2 are siblings
305
    is(scalar(@result), 2, 'get_hold_libraries returns 2 libraries');
305
    is(scalar(@result), 2, 'get_hold_libraries returns 2 libraries');
306
306
Lines 310-316 subtest 'get_hold_libraries and validate_hold_sibling' => sub { Link Here
310
        ok(exists $map{$hold_library->branchcode}, 'library in hold group');
310
        ok(exists $map{$hold_library->branchcode}, 'library in hold group');
311
    }
311
    }
312
312
313
    @result = $library3->get_hold_libraries();
313
    @result = $library3->get_hold_libraries()->as_list;
314
    # library3, library4 and library5 are siblings
314
    # library3, library4 and library5 are siblings
315
    is(scalar(@result), 3, 'get_hold_libraries returns 3 libraries');
315
    is(scalar(@result), 3, 'get_hold_libraries returns 3 libraries');
316
316
(-)a/t/db_dependent/Koha/Patron.t (-2 / +2 lines)
Lines 241-247 subtest 'add_enrolment_fee_if_needed() tests' => sub { Link Here
241
        $enrollment_fee = $patron->add_enrolment_fee_if_needed(1);
241
        $enrollment_fee = $patron->add_enrolment_fee_if_needed(1);
242
        is( $patron->account->balance * 1, 60, 'Patron charged the enrolment fees' );
242
        is( $patron->account->balance * 1, 60, 'Patron charged the enrolment fees' );
243
243
244
        my @debits = $account->outstanding_debits;
244
        my @debits = $account->outstanding_debits->as_list;
245
        is( scalar @debits, 3, '3 enrolment fees' );
245
        is( scalar @debits, 3, '3 enrolment fees' );
246
        is( $debits[0]->debit_type_code, 'ACCOUNT', 'Account type set correctly' );
246
        is( $debits[0]->debit_type_code, 'ACCOUNT', 'Account type set correctly' );
247
        is( $debits[1]->debit_type_code, 'ACCOUNT', 'Account type set correctly' );
247
        is( $debits[1]->debit_type_code, 'ACCOUNT', 'Account type set correctly' );
Lines 279-285 subtest 'add_enrolment_fee_if_needed() tests' => sub { Link Here
279
        my $account = $patron->account;
279
        my $account = $patron->account;
280
        is( $patron->account->balance, 0, 'Patron not charged anything' );
280
        is( $patron->account->balance, 0, 'Patron not charged anything' );
281
281
282
        my @debits = $account->outstanding_debits;
282
        my @debits = $account->outstanding_debits->as_list;
283
        is( scalar @debits, 0, 'no debits' );
283
        is( scalar @debits, 0, 'no debits' );
284
284
285
        $schema->storage->txn_rollback;
285
        $schema->storage->txn_rollback;
(-)a/t/db_dependent/Koha/Patron/Modifications.t (-1 / +1 lines)
Lines 223-229 subtest 'approve tests' => sub { Link Here
223
    my @patron_attributes
223
    my @patron_attributes
224
        = map { $_->unblessed }
224
        = map { $_->unblessed }
225
        Koha::Patron::Attributes->search(
225
        Koha::Patron::Attributes->search(
226
        { borrowernumber => $patron->borrowernumber } );
226
        { borrowernumber => $patron->borrowernumber } )->as_list;
227
227
228
    is( $patron_attributes[0]->{code},
228
    is( $patron_attributes[0]->{code},
229
        'CODE_1', 'Untouched attribute type is preserved (code)' );
229
        'CODE_1', 'Untouched attribute type is preserved (code)' );
(-)a/t/db_dependent/Koha/Patrons.t (-12 / +7 lines)
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
- 

Return to bug 29844