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

(-)a/Koha/Biblio.pm (+16 lines)
Lines 39-44 use Koha::Cache::Memory::Lite; Link Here
39
use Koha::Checkouts;
39
use Koha::Checkouts;
40
use Koha::CirculationRules;
40
use Koha::CirculationRules;
41
use Koha::Exceptions;
41
use Koha::Exceptions;
42
use Koha::Illrequests;
42
use Koha::Item::Transfer::Limits;
43
use Koha::Item::Transfer::Limits;
43
use Koha::Items;
44
use Koha::Items;
44
use Koha::Libraries;
45
use Koha::Libraries;
Lines 164-169 sub tickets { Link Here
164
    return Koha::Tickets->_new_from_dbic( $rs );
165
    return Koha::Tickets->_new_from_dbic( $rs );
165
}
166
}
166
167
168
=head3 ill_requests
169
170
    my $ill_requests = $biblio->ill_requests();
171
172
Returns a Koha::Illrequests object
173
174
=cut
175
176
sub ill_requests {
177
    my ( $self ) = @_;
178
179
    my $ill_requests = $self->_result->ill_requests;
180
    return Koha::Illrequests->_new_from_dbic($ill_requests);
181
}
182
167
=head3 item_groups
183
=head3 item_groups
168
184
169
my $item_groups = $biblio->item_groups();
185
my $item_groups = $biblio->item_groups();
(-)a/Koha/Schema/Result/Biblio.pm (+7 lines)
Lines 611-616 __PACKAGE__->has_many( Link Here
611
  { cascade_copy => 0, cascade_delete => 0 },
611
  { cascade_copy => 0, cascade_delete => 0 },
612
);
612
);
613
613
614
__PACKAGE__->has_many(
615
  "ill_requests",
616
  "Koha::Schema::Result::Illrequest",
617
  { "foreign.biblio_id" => "self.biblionumber" },
618
  { cascade_copy => 0, cascade_delete => 0 },
619
);
620
614
__PACKAGE__->has_one(
621
__PACKAGE__->has_one(
615
  "metadata",
622
  "metadata",
616
  "Koha::Schema::Result::BiblioMetadata",
623
  "Koha::Schema::Result::BiblioMetadata",
(-)a/t/db_dependent/Koha/Biblio.t (-2 / +27 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 23; # +1
20
use Test::More tests => 24;
21
use Test::Exception;
21
use Test::Exception;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 1061-1066 subtest 'Recalls tests' => sub { Link Here
1061
    $schema->storage->txn_rollback;
1061
    $schema->storage->txn_rollback;
1062
};
1062
};
1063
1063
1064
subtest 'ill_requests() tests' => sub {
1065
1066
    plan tests => 3;
1067
1068
    $schema->storage->txn_begin;
1069
1070
    my $biblio = $builder->build_sample_biblio;
1071
1072
    my $rs = $biblio->ill_requests;
1073
    is( ref($rs), 'Koha::Illrequests' );
1074
    is( $rs->count, 0, 'No linked requests' );
1075
1076
    foreach ( 1..10 ) {
1077
        $builder->build_object(
1078
            {
1079
                class => 'Koha::Illrequests',
1080
                value => { biblio_id => $biblio->id }
1081
            }
1082
        );
1083
    }
1084
1085
    is( $biblio->ill_requests->count, 10, 'Linked requests are present' );
1086
1087
    $schema->storage->txn_rollback;
1088
};
1089
1064
subtest 'item_groups() tests' => sub {
1090
subtest 'item_groups() tests' => sub {
1065
1091
1066
    plan tests => 6;
1092
    plan tests => 6;
1067
- 

Return to bug 21983