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

(-)a/Koha/Biblio.pm (+16 lines)
Lines 34-39 use base qw(Koha::Object); Link Here
34
use Koha::Acquisition::Orders;
34
use Koha::Acquisition::Orders;
35
use Koha::ArticleRequests;
35
use Koha::ArticleRequests;
36
use Koha::Biblio::Metadatas;
36
use Koha::Biblio::Metadatas;
37
use Koha::Biblio::ItemGroups;
37
use Koha::Biblioitems;
38
use Koha::Biblioitems;
38
use Koha::Checkouts;
39
use Koha::Checkouts;
39
use Koha::CirculationRules;
40
use Koha::CirculationRules;
Lines 118-123 sub active_orders { Link Here
118
    return $self->orders->search({ datecancellationprinted => undef });
119
    return $self->orders->search({ datecancellationprinted => undef });
119
}
120
}
120
121
122
=head3 item_groups
123
124
my $item_groups = $biblio->item_groups();
125
126
Returns a Koha::Biblio::ItemGroups object
127
128
=cut
129
130
sub item_groups {
131
    my ( $self ) = @_;
132
133
    my $item_groups = $self->_result->item_groups;
134
    return Koha::Biblio::ItemGroups->_new_from_dbic($item_groups);
135
}
136
121
=head3 can_article_request
137
=head3 can_article_request
122
138
123
my $bool = $biblio->can_article_request( $borrower );
139
my $bool = $biblio->can_article_request( $borrower );
(-)a/Koha/Item.pm (+22 lines)
Lines 30-35 use C4::Reserves; Link Here
30
use C4::ClassSource qw( GetClassSort );
30
use C4::ClassSource qw( GetClassSort );
31
use C4::Log qw( logaction );
31
use C4::Log qw( logaction );
32
32
33
use Koha::Biblio::ItemGroups;
33
use Koha::Checkouts;
34
use Koha::Checkouts;
34
use Koha::CirculationRules;
35
use Koha::CirculationRules;
35
use Koha::CoverImages;
36
use Koha::CoverImages;
Lines 403-408 sub checkout { Link Here
403
    return Koha::Checkout->_new_from_dbic( $checkout_rs );
404
    return Koha::Checkout->_new_from_dbic( $checkout_rs );
404
}
405
}
405
406
407
=head3 item_group
408
409
my $item_group = $item->item_group;
410
411
Return the item group for this item
412
413
=cut
414
415
sub item_group {
416
    my ( $self ) = @_;
417
418
    my $item_group_item = $self->_result->item_group_item;
419
    return unless $item_group_item;
420
421
    my $item_group_rs = $item_group_item->item_group;
422
    return unless $item_group_rs;
423
424
    my $item_group = Koha::Biblio::ItemGroup->_new_from_dbic( $item_group_rs );
425
    return $item_group;
426
}
427
406
=head3 holds
428
=head3 holds
407
429
408
my $holds = $item->holds();
430
my $holds = $item->holds();
(-)a/t/db_dependent/Koha/Biblio.t (-1 / +28 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 21; # +1
20
use Test::More tests => 22; # +1
21
use Test::Warn;
21
use Test::Warn;
22
22
23
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc );
23
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc );
Lines 1001-1006 subtest 'Recalls tests' => sub { Link Here
1001
    $schema->storage->txn_rollback;
1001
    $schema->storage->txn_rollback;
1002
};
1002
};
1003
1003
1004
subtest 'item_groups() tests' => sub {
1005
1006
    plan tests => 6;
1007
1008
    $schema->storage->txn_begin;
1009
1010
    my $biblio = $builder->build_sample_biblio();
1011
1012
    my @item_groups = $biblio->item_groups->as_list;
1013
    is( scalar(@item_groups), 0, 'Got zero item groups');
1014
1015
    my $item_group_1 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store();
1016
1017
    @item_groups = $biblio->item_groups->as_list;
1018
    is( scalar(@item_groups), 1, 'Got one item group');
1019
    is( $item_groups[0]->id, $item_group_1->id, 'Got correct item group');
1020
1021
    my $item_group_2 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store();
1022
1023
    @item_groups = $biblio->item_groups->as_list;
1024
    is( scalar(@item_groups), 2, 'Got two item groups');
1025
    is( $item_groups[0]->id, $item_group_1->id, 'Got correct item group 1');
1026
    is( $item_groups[1]->id, $item_group_2->id, 'Got correct item group 2');
1027
1028
    $schema->storage->txn_rollback;
1029
};
1030
1004
sub component_record1 {
1031
sub component_record1 {
1005
    my $marc = MARC::Record->new;
1032
    my $marc = MARC::Record->new;
1006
    $marc->append_fields(
1033
    $marc->append_fields(
(-)a/t/db_dependent/Koha/Item.t (-2 / +25 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use utf8;
21
use utf8;
22
22
23
use Test::More tests => 15;
23
use Test::More tests => 16;
24
use Test::Exception;
24
use Test::Exception;
25
25
26
use C4::Biblio qw( GetMarcSubfieldStructure );
26
use C4::Biblio qw( GetMarcSubfieldStructure );
Lines 1420-1422 subtest 'Recalls tests' => sub { Link Here
1420
    $schema->storage->txn_rollback;
1420
    $schema->storage->txn_rollback;
1421
};
1421
};
1422
1422
1423
- 
1423
subtest 'item_group() tests' => sub {
1424
1425
    plan tests => 4;
1426
1427
    $schema->storage->txn_begin;
1428
1429
    my $biblio = $builder->build_sample_biblio();
1430
    my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1431
    my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1432
1433
    is( $item_1->item_group, undef, 'Item 1 has no item group');
1434
    is( $item_2->item_group, undef, 'Item 2 has no item group');
1435
1436
    my $item_group_1 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store();
1437
    my $item_group_2 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store();
1438
1439
    $item_group_1->add_item({ item_id => $item_1->id });
1440
    $item_group_2->add_item({ item_id => $item_2->id });
1441
1442
    is( $item_1->item_group->id, $item_group_1->id, 'Got item group 1 correctly' );
1443
    is( $item_2->item_group->id, $item_group_2->id, 'Got item group 2 correctly' );
1444
1445
    $schema->storage->txn_rollback;
1446
};

Return to bug 24857