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 (-4 / +26 lines)
Lines 31-52 use C4::ClassSource qw( GetClassSort ); Link Here
31
use C4::Log qw( logaction );
31
use C4::Log qw( logaction );
32
32
33
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
33
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
34
use Koha::Biblio::ItemGroups;
34
use Koha::Checkouts;
35
use Koha::Checkouts;
35
use Koha::CirculationRules;
36
use Koha::CirculationRules;
36
use Koha::CoverImages;
37
use Koha::CoverImages;
37
use Koha::SearchEngine::Indexer;
38
use Koha::Exceptions::Item::Transfer;
38
use Koha::Exceptions::Item::Transfer;
39
use Koha::Item::Attributes;
39
use Koha::Item::Transfer::Limits;
40
use Koha::Item::Transfer::Limits;
40
use Koha::Item::Transfers;
41
use Koha::Item::Transfers;
41
use Koha::Item::Attributes;
42
use Koha::ItemTypes;
42
use Koha::ItemTypes;
43
use Koha::Libraries;
43
use Koha::Patrons;
44
use Koha::Patrons;
44
use Koha::Plugins;
45
use Koha::Plugins;
45
use Koha::Libraries;
46
use Koha::Result::Boolean;
47
use Koha::SearchEngine::Indexer;
46
use Koha::StockRotationItem;
48
use Koha::StockRotationItem;
47
use Koha::StockRotationRotas;
49
use Koha::StockRotationRotas;
48
use Koha::TrackedLinks;
50
use Koha::TrackedLinks;
49
use Koha::Result::Boolean;
50
51
51
use base qw(Koha::Object);
52
use base qw(Koha::Object);
52
53
Lines 416-421 sub checkout { Link Here
416
    return Koha::Checkout->_new_from_dbic( $checkout_rs );
417
    return Koha::Checkout->_new_from_dbic( $checkout_rs );
417
}
418
}
418
419
420
=head3 item_group
421
422
my $item_group = $item->item_group;
423
424
Return the item group for this item
425
426
=cut
427
428
sub item_group {
429
    my ( $self ) = @_;
430
431
    my $item_group_item = $self->_result->item_group_item;
432
    return unless $item_group_item;
433
434
    my $item_group_rs = $item_group_item->item_group;
435
    return unless $item_group_rs;
436
437
    my $item_group = Koha::Biblio::ItemGroup->_new_from_dbic( $item_group_rs );
438
    return $item_group;
439
}
440
419
=head3 holds
441
=head3 holds
420
442
421
my $holds = $item->holds();
443
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
use Test::MockModule;
25
use Test::MockModule;
26
26
Lines 1454-1456 subtest 'Recalls tests' => sub { Link Here
1454
    $schema->storage->txn_rollback;
1454
    $schema->storage->txn_rollback;
1455
};
1455
};
1456
1456
1457
- 
1457
subtest 'item_group() tests' => sub {
1458
1459
    plan tests => 4;
1460
1461
    $schema->storage->txn_begin;
1462
1463
    my $biblio = $builder->build_sample_biblio();
1464
    my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1465
    my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1466
1467
    is( $item_1->item_group, undef, 'Item 1 has no item group');
1468
    is( $item_2->item_group, undef, 'Item 2 has no item group');
1469
1470
    my $item_group_1 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store();
1471
    my $item_group_2 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store();
1472
1473
    $item_group_1->add_item({ item_id => $item_1->id });
1474
    $item_group_2->add_item({ item_id => $item_2->id });
1475
1476
    is( $item_1->item_group->id, $item_group_1->id, 'Got item group 1 correctly' );
1477
    is( $item_2->item_group->id, $item_group_2->id, 'Got item group 2 correctly' );
1478
1479
    $schema->storage->txn_rollback;
1480
};

Return to bug 24857